NAME
read_image -- create unit to read sequence of images
PROTOTYPE
unitptr read_image( int iDx, int iDy, char *pcFileName, unitptr uHost)
ARGUMENTS
- int iDx
- image width in pixels
- int iDy
- image height in pixels
- char *pcFileName
- image file. Format is Path/File.Type. to access a sequence of files Path/File\#.Type, where \# is a running index that is counted by this unit.
- unitptr uHost
- host unit
RETURN VALUE:
A pointer to the created unit or NULL in the case of an error.
INTERFACE OF CREATED UNIT:
- X_in[1]:
- (input field 0) index of next image to be accessed
- Y_in[1]:
- (input field 1) reset limit of index value
- CTL_in[1]:
- (control field) controls counting mode (see below)
- X_out[iDx*iDy]:
- (packed output field 0) image gray - data
- Y_out[iDx*iDy]:
- (packed output field 1) image red - data
- Z_out[iDx*iDy]:
- (packed output field 2) image green - data
- out_3[iDx*iDy]:
- (packed output field 3) image blue - data
- out_4[2]:
- (output field 4) width and height (in pixels) of image read.
Third pin (value 1..6) indicates which format
(P1..P6) the read pxm-file has.
- out_5[1]:
- (output field 5) index of last image read.
Note: all specified fields are present, even if only gray level
images are read. In this case, the contents of out_1..out_3
are meaningless.
EXECUTION OF CREATED UNIT:
The first exec - call reads image Path/File#.Type, where #=X_in[0] (the
data for this image is already available after the creation call
of the unit, i.e., the first exec-call actually does nothing).
Each subsequent exec - call reads one further
image from a file. The accessed file
is determined from pcFileName and the input values at input fields
0..2 according to the following rules:
- if CTL_in[0] = 0:
- do nothing.
- if CTL_in[0] != 0:
- increment internal counter value # by
value at CTL_in[0]. If the resulting interval [X_in[0], #]
contains the value Y_in[0], reset # to value at X_in[0].
Then read image data from file Path/File#.Type, where # = final
(incremented or reset) value of internal counter.
These two rules allow simple reading of image sequences either
in arbitrary order (if X_in[0]==.Y_in[0] and CTL_in[0]=1),
or in the cyclic fashion: for ( i=X_in[0]; i<Y_in[0]; i+=CTL_in[0] ).
INITIALIZATION:
A call ctrl_unit(NST_INIT,u) or ctrl_unit(NST_RESET,u)
reads image Path/File#.Type with
# = X_in[0] and sets iCounter to X_in[0]. The next exec-call
will resume at image #.
SEE ALSO:
read_data, read_file, write_data, write_file, data_store
FILE
/homes/jontrup/nst5/man/../o.sol2//../foldersrc/nst_file.c