1funimageget(3)                SAORD Documentation               funimageget(3)
2
3
4

NAME

6       FunImageGet - get an image or image section
7

SYNOPSIS

9         #include <funtools.h>
10
11         void *FunImageGet(Fun fun, void *buf, char *plist)
12

DESCRIPTION

14       The FunImageGet() routine returns an binned image array of the speci‐
15       fied section of a Funtools data file.  If the input data are already of
16       type image, the array is generated by extracting the specified image
17       section and then binning it according to the specified bin factor.  If
18       the input data are contained in a binary table or raw event file, the
19       rows are binned on the columns specified by the bincols= keyword (using
20       appropriate default columns as necessary), after which the image sec‐
21       tion and bin factors are applied. In both cases, the data is automati‐
22       cally converted from FITS to native format, if necessary.
23
24       The first argument is the Funtools handle returned by FunOpen().  The
25       second buf argument is a pointer to a data buffer to fill. If NULL is
26       specified, FunImageGet will allocate a buffer of the appropriate size.
27       Generally speaking, you always want Funtools to allocate the buffer
28       because the image dimensions will be determined by Funtools image sec‐
29       tioning on the command line.
30
31       The third plist (i.e., parameter list) argument is a string containing
32       one or more comma-delimited keyword=value parameters.  It can be used
33       to specify the return data type using the bitpix= keyword.  If no such
34       keyword is specified in the plist string, the data type of the returned
35       image is the same as the data type of the original input file, or is of
36       type int for FITS binary tables.
37
38       If the bitpix= keyword is supplied in the plist string, the data type
39       of the returned image will be one of the supported FITS image data
40       types:
41
42       ·   8 unsigned char
43
44       ·   16 short
45
46       ·   32 int
47
48       ·   -32 float
49
50       ·   -64 double
51
52       For example:
53
54         void *buf;
55         /* extract data section into an image buffer */
56         if( !(buf = FunImageGet(fun, NULL, NULL)) )
57           gerror(stderr, "could not FunImageGet: %s\n", iname);
58
59       will allocate buf and retrieve the image in the file data format. In
60       this case, you will have to determine the data type (using the
61       FUN_SECT_BITPIX value in the FunInfoGet() routine) and then use a
62       switch statement to process each data type:
63
64         int bitpix;
65         void *buf;
66         unsigned char *cbuf;
67         short *sbuf;
68         int *ibuf;
69         ...
70         buf = FunImageGet(fun, NULL, NULL);
71         FunInfoGet(fun, FUN_SECT_BITPIX,  &bitpix, 0);
72         /* set appropriate data type buffer to point to image buffer */
73         switch(bitpix){
74         case 8:
75           cbuf = (unsigned char *)buf; break;
76         case 16:
77           sbuf = (short *)buf; break;
78         case 32:
79           ibuf = (int *)buf; break;
80        ...
81
82       See the imblank example code for more details on how to process an
83       image when the data type is not specified beforehand.
84
85       It often is easier to specify the data type directly:
86
87         double *buf;
88         /* extract data section into a double image buffer */
89         if( !(buf = FunImageGet(fun, NULL, "bitpix=-64")) )
90           gerror(stderr, "could not FunImageGet: %s\n", iname);
91
92       will extract the image while converting to type double.
93
94       On success, a pointer to the image buffer is returned. (This will be
95       the same as the second argument, if NULL is not passed to the latter.)
96       On error, NULL is returned.
97
98       In summary, to retrieve image or row data into a binned image, you sim‐
99       ply call FunOpen() followed by FunImageGet().  Generally, you then will
100       want to call FunInfoGet() to retrieve the axis dimensions (and data
101       type) of the section you are processing (so as to take account of sec‐
102       tioning and blocking of the original data):
103
104         double *buf;
105         int i, j;
106         int dim1, dim2;
107         ... other declarations, etc.
108
109         /* open the input FITS file */
110         if( !(fun = FunOpen(argv[1], "rc", NULL)) )
111           gerror(stderr, "could not FunOpen input file: %s\n", argv[1]);
112
113         /* extract and bin the data section into a double float image buffer */
114         if( !(buf = FunImageGet(fun, NULL, "bitpix=-64")) )
115           gerror(stderr, "could not FunImageGet: %s\n", argv[1]);
116
117         /* get dimension information from funtools structure */
118         FunInfoGet(fun, FUN_SECT_DIM1, &dim1, FUN_SECT_DIM2, &dim2, 0);
119
120         /* loop through pixels and reset values below limit to value */
121         for(i=0; i<dim1*dim2; i++){
122           if( buf[i] <= blimit ) buf[i] = bvalue;
123         }
124
125       Another useful plist string value is "mask=all", which returns an image
126       populated with regions id values. Image pixels within a region will
127       contain the associated region id (region values start at 1), and other‐
128       wise will contain a 0 value. Thus, the returned image is a region mask
129       which can be used to process the image data (which presumably is
130       retrieved by a separate call to FunImageGet) pixel by pixel.
131
132       If a FITS binary table or a non-FITS raw event file is being binned
133       into an image, it is necessary to specify the two columns that will be
134       used in the 2D binning.  This usually is done on the command line using
135       the bincols=(x,y) keyword:
136
137         funcnts "foo.ev[EVENTS,bincols=(detx,dety)]"
138
139       The full form of the bincols= specifier is:
140
141         bincols=([xname[:tlmin[:tlmax:[binsiz]]]],[yname[:tlmin[:tlmax[:binsiz]]]])
142
143       where the tlmin, tlmax, and binsiz specifiers determine the image bin‐
144       ning dimensions:
145
146         dim = (tlmax - tlmin)/binsiz     (floating point data)
147         dim = (tlmax - tlmin)/binsiz + 1 (integer data)
148
149       These tlmin, tlmax, and binsiz specifiers can be omitted if TLMIN,
150       TLMAX, and TDBIN header parameters (respectively) are present in the
151       FITS binary table header for the column in question.  Note that if only
152       one parameter is specified, it is assumed to be tlmax, and tlmin
153       defaults to 1. If two parameters are specified, they are assumed to be
154       tlmin and tlmax.
155
156       If bincols is not specified on the command line, Funtools tries to use
157       appropriate defaults: it looks for the environment variable FITS_BIN‐
158       COLS (or FITS_BINKEY). Then it looks for the Chandra parameters CPREF
159       (or PREFX) in the FITS binary table header. Failing this, it looks for
160       columns named "X" and "Y" and if these are not found, it looks for col‐
161       umns containing the characters "X" and "Y".
162
163       See Binning FITS Binary Tables and Non-FITS Event Files for more infor‐
164       mation.
165

SEE ALSO

167       See funtools(n) for a list of Funtools help pages
168
169
170
171version 1.4.0                   August 15, 2007                 funimageget(3)
Impressum