~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-libs/tina/image/img_GenDef.h

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  *
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  *
  6  * Redistribution and use in source and binary forms, with or without modification,
  7  * are permitted provided that the following conditions are met:
  8  *
  9  *   . Redistributions of source code must retain the above copyright notice,
 10  *     this list of conditions and the following disclaimer.
 11  *
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation
 14  *     and/or other materials provided with the distribution.
 15  *
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this
 18  *     software without specific prior written permission.
 19  *
 20  *
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  *
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/image/img_GenDef.h,v $
 37  * Date    :  $Date: 2008/12/07 02:27:36 $
 38  * Version :  $Revision: 1.7 $
 39  * CVS Id  :  $Id: img_GenDef.h,v 1.7 2008/12/07 02:27:36 paul Exp $
 40  *
 41  * Notes :  Image handling headers
 42  *
 43  *********
 44  * Author  : Legacy TINA
 45  */
 46  /**
 47  * @file
 48  * @brief Definitions of imrect, imregion, and macros to get or set image data.
 49  *
 50  * Definitions of imrect, imregion, and macros to get or set image data.
 51  */
 52 
 53 #ifndef TINA_IMG_GEN_DEF_HDR
 54 #define TINA_IMG_GEN_DEF_HDR
 55 
 56 #include <tina/sys/sysDef.h>
 57 
 58 /**
 59  * @brief Definition of imregion, the TINA rectangular region of interest data structure.
 60  *
 61  * Definition of  imregion, the TINA rectangular region of interest data structure. The fields are:
 62  * ts_id   TINA structure identifier.
 63  * lx, ux  Lower and upper extent of the region in x (spanning across image columns).
 64  * ly, uy  Lower and upper extent of the region in y (spanning across image rows).
 65  */
 66 typedef struct imregion
 67 {
 68     Ts_id ts_id;                
 69     int     lx, ly;             
 70     int     ux, uy;             
 71 }       Imregion;
 72 #define IMREGION_SWAP_STRING "iiii"
 73 
 74 /**
 75  * @brief Definition of imrect, the TINA image data structure.
 76  *
 77  * Definition of imrect, the TINA image data structure. The fields are:
 78  * ts_id TINA structure identifier.
 79  * vtype Variable type of the image data.
 80  * width, height Width (no of columns) and height (no of rows) in the image.
 81  * region The region of interest associsted with the image.
 82  * data The image data, as an array of pointers to the image rows.
 83  * props Freeform list of image properties, particularly the extras for an edge rect.
 84  *
 85  * Experimental colour display code (PAB 06/09/2009): the following three fields hold
 86  * colour data corresponding to the intensity data held in the data array.  The design 
 87  * philosophy is that they will be set to NULL in im_alloc, and will be assumed (if 
 88  * non-NULL) to point to arrays of the same type and dimensions as the data array.  
 89  * They will be freed in im_free if non-NULL using these assumptions.
 90  * Basic image handling functions (im_alloc, im_free etc.: all of the functions in 
 91  * imgGen_alloc.c) have been updated to handle the new fields. However, much of the 
 92  * algorithmic functionality of TINA is (un/poorly-)defined for colour images, and so 
 93  * will not alter the colour fields.
 94  *
 95  * datar The red value of each pixel, as an array of pointers to the image rows.
 96  * datag The green value of each pixel, as an array of pointers to the image rows.
 97  * datab The blue value of each pixel, as an array of pointers to the image rows.
 98  *
 99  */
100 typedef struct imrect
101 {
102     Ts_id ts_id;
103     Vartype vtype;
104     int     width, height;
105     Imregion *region;
106     void   *data;
107     List *props;
108     void   *rdata;
109     void   *gdata;
110     void   *bdata;
111 
112 }       Imrect;
113 #define IMRECT_SWAP_STRING "iiippp"
114 
115 
116 /**
117  * @brief Variable-type specific macros to access image pixel data.
118  * @param _im The image to access.
119  * @param _i The row number of the pixel.
120  * @params _j The column number of the pixel.
121  * 
122  * These macros access the pixel i,j in the input image. They are intended to be called through 
123  * IM_PIX_GET, IM_PIX_GETP, or IM_PIX_SET, which call the correct macro on the basis of the variable 
124  * type of the input image.
125  */
126 #define IM_CHAR(_im,_i,_j)      (((char **)(_im)->data)[(_i)][(_j)])
127 #define IM_UCHAR(_im,_i,_j)     (((unsigned char **)(_im)->data)[(_i)][(_j)])
128 #define IM_SHORT(_im,_i,_j)     (((short **)(_im)->data)[(_i)][(_j)])
129 #define IM_USHORT(_im,_i,_j)    (((unsigned short **)(_im)->data)[(_i)][(_j)])
130 #define IM_INT(_im,_i,_j)       (((int **)(_im)->data)[(_i)][(_j)])
131 #define IM_UINT(_im,_i,_j)      (((unsigned int **)(_im)->data)[(_i)][(_j)])
132 #define IM_FLOAT(_im,_i,_j)     (((float **)(_im)->data)[(_i)][(_j)])
133 #define IM_DOUBLE(_im,_i,_j)    (((double **)(_im)->data)[(_i)][(_j)])
134 #define IM_COMPLEX(_im,_i,_j)   (((Complex **)(_im)->data)[(_i)][(_j)])
135 #define IM_PTR(_im,_i,_j)       (((void ***)(_im)->data)[(_i)][(_j)])
136 
137 #define IM_VRAM0(_im,_i,_j)  \
138 (((Vram **)(_im)->data)[(_i)][(_j)].vram0)
139 
140 #define IM_VRAM1(_im,_i,_j) \
141 (((Vram **)(_im)->data)[(_i)][(_j)].vram1)
142 
143 #define IM_VRAM2(_im,_i,_j) \
144 (((Vram **)(_im)->data)[(_i)][(_j)].vram2)
145 
146 #define IM_VRAM3(_im,_i,_j) \
147 (((Vram **)(_im)->data)[(_i)][(_j)].vram3)
148 
149 
150 /**
151  * @brief Variable-type specific macros to access image pixel red data.
152  * @param _im The image to access.
153  * @param _i The row number of the pixel.
154  * @params _j The column number of the pixel.
155  * 
156  * These macros access the red value of the pixel i,j in the input image. They are 
157  * intended to be called through IM_R_PIX_GET, IM_R_PIX_GETP, or IM_R_PIX_SET, which 
158  * call the correct macro on the basis of the variable type of the input image.
159  *
160  * Note: only types that resolve to a single number are implemented
161  *
162  */
163 #define IM_R_CHAR(_im,_i,_j)      (((char **)(_im)->rdata)[(_i)][(_j)])
164 #define IM_R_UCHAR(_im,_i,_j)     (((unsigned char **)(_im)->rdata)[(_i)][(_j)])
165 #define IM_R_SHORT(_im,_i,_j)     (((short **)(_im)->rdata)[(_i)][(_j)])
166 #define IM_R_USHORT(_im,_i,_j)    (((unsigned short **)(_im)->rdata)[(_i)][(_j)])
167 #define IM_R_INT(_im,_i,_j)       (((int **)(_im)->rdata)[(_i)][(_j)])
168 #define IM_R_UINT(_im,_i,_j)      (((unsigned int **)(_im)->rdata)[(_i)][(_j)])
169 #define IM_R_FLOAT(_im,_i,_j)     (((float **)(_im)->rdata)[(_i)][(_j)])
170 #define IM_R_DOUBLE(_im,_i,_j)    (((double **)(_im)->rdata)[(_i)][(_j)])
171 
172 
173 /**
174  * @brief Variable-type specific macros to access image pixel green data.
175  * @param _im The image to access.
176  * @param _i The row number of the pixel.
177  * @params _j The column number of the pixel.
178  * 
179  * These macros access the green value of the pixel i,j in the input image. They are 
180  * intended to be called through IM_G_PIX_GET, IM_G_PIX_GETP, or IM_G_PIX_SET, which 
181  * call the correct macro on the basis of the variable type of the input image.
182  *
183  * Note: only types that resolve to a single number are implemented
184  *
185  */
186 #define IM_G_CHAR(_im,_i,_j)      (((char **)(_im)->gdata)[(_i)][(_j)])
187 #define IM_G_UCHAR(_im,_i,_j)     (((unsigned char **)(_im)->gdata)[(_i)][(_j)])
188 #define IM_G_SHORT(_im,_i,_j)     (((short **)(_im)->gdata)[(_i)][(_j)])
189 #define IM_G_USHORT(_im,_i,_j)    (((unsigned short **)(_im)->gdata)[(_i)][(_j)])
190 #define IM_G_INT(_im,_i,_j)       (((int **)(_im)->gdata)[(_i)][(_j)])
191 #define IM_G_UINT(_im,_i,_j)      (((unsigned int **)(_im)->gdata)[(_i)][(_j)])
192 #define IM_G_FLOAT(_im,_i,_j)     (((float **)(_im)->gdata)[(_i)][(_j)])
193 #define IM_G_DOUBLE(_im,_i,_j)    (((double **)(_im)->gdata)[(_i)][(_j)])
194 
195 
196 /**
197  * @brief Variable-type specific macros to access image pixel blue data.
198  * @param _im The image to access.
199  * @param _i The row number of the pixel.
200  * @params _j The column number of the pixel.
201  * 
202  * These macros access the blue value of the pixel i,j in the input image. They are 
203  * intended to be called through IM_B_PIX_GET, IM_B_PIX_GETP, or IM_B_PIX_SET, which 
204  * call the correct macro on the basis of the variable type of the input image.
205  *
206  * Note: only types that resolve to a single number are implemented
207  *
208  */
209 #define IM_B_CHAR(_im,_i,_j)      (((char **)(_im)->bdata)[(_i)][(_j)])
210 #define IM_B_UCHAR(_im,_i,_j)     (((unsigned char **)(_im)->bdata)[(_i)][(_j)])
211 #define IM_B_SHORT(_im,_i,_j)     (((short **)(_im)->bdata)[(_i)][(_j)])
212 #define IM_B_USHORT(_im,_i,_j)    (((unsigned short **)(_im)->bdata)[(_i)][(_j)])
213 #define IM_B_INT(_im,_i,_j)       (((int **)(_im)->bdata)[(_i)][(_j)])
214 #define IM_B_UINT(_im,_i,_j)      (((unsigned int **)(_im)->bdata)[(_i)][(_j)])
215 #define IM_B_FLOAT(_im,_i,_j)     (((float **)(_im)->bdata)[(_i)][(_j)])
216 #define IM_B_DOUBLE(_im,_i,_j)    (((double **)(_im)->bdata)[(_i)][(_j)])
217 
218 
219 /**
220  * @brief Macro to read image pixel data
221  * @param _im The image to read data from.
222  * @param _i The row number of the pixel.
223  * @params _j The column number of the pixel.
224  * @param _gl Pixel value at the desired coordinates.
225  * 
226  * This macro wraps the variable-type specific macros to access image pixel values, calling the correct one on
227  * the basis of the variable type of the input image.  It returns the value held in the image at the 
228  * specified pixel coordinates. For types (signed and unsigned) char short and int, float, and double,
229  * the pixel value itself is returned.  For complex images, the real part of the complex number is 
230  * returned: use IM_PIX_GETZ if you want the complex number itself. 
231  * 
232  * PAB 05/12/2008: The operation is undefined for pointer images and results in a fatal error: use
233  * IM_PIX_GETP instead.
234  */
235 #define IM_PIX_GET(_im, _i, _j, _gl) \
236         switch ((_im)->vtype) \
237         {\
238              case char_v: (_gl)       = (char) IM_CHAR((_im),(_i),(_j)); \
239                           break;\
240              case uchar_v: (_gl)      = (unsigned char) IM_UCHAR((_im),(_i),(_j)); \
241                           break;\
242              case short_v: (_gl)      = (short) IM_SHORT((_im),(_i),(_j)); \
243                           break;\
244              case ushort_v: (_gl)     = (unsigned short) IM_USHORT((_im),(_i),(_j)); \
245                           break;\
246              case int_v: (_gl)        = (int) IM_INT((_im),(_i),(_j)); \
247                           break;\
248              case uint_v: (_gl)       = (unsigned int) IM_UINT((_im),(_i),(_j)); \
249                           break;\
250              case float_v: (_gl)      = (float) IM_FLOAT((_im),(_i),(_j)); \
251                           break;\
252              case double_v: (_gl)     = (double) IM_DOUBLE((_im),(_i),(_j)); \
253                           break;\
254              case complex_v: (_gl)    = (double) IM_COMPLEX((_im),(_i),(_j)).x; \
255                           break;\
256              case ptr_v:  (_gl) = 0;\
257                           error ("IM_PIX_GET not implemented for pointer images: use IM_PIX_GETP instead\n", fatal);\
258                           break;\
259              case vram0_v: (_gl)      = (unsigned char) IM_VRAM0((_im),(_i),(_j)); \
260                           break;\
261              case vram1_v: (_gl)      = (unsigned char) IM_VRAM1((_im),(_i),(_j)); \
262                           break;\
263              case vram2_v: (_gl)      = (unsigned char) IM_VRAM2((_im),(_i),(_j)); \
264                           break;\
265              case vram3_v: (_gl)      = (unsigned char) IM_VRAM3((_im),(_i),(_j)); \
266                           break;\
267              default:\
268                           (_gl) = 0;\
269                           error ("IM_PIX_GET: unknown pixel type", fatal);\
270                           break;\
271         }
272 
273 
274 /**
275  * @brief Macro to read image red pixel data
276  * @param _im The image to read data from.
277  * @param _i The row number of the pixel.
278  * @params _j The column number of the pixel.
279  * @param _gl Pixel red value at the desired coordinates.
280  * 
281  * This macro wraps the variable-type specific macros to access image red pixel values, calling 
282  * the correct one on the basis of the variable type of the input image.  It returns the red value 
283  * held in the image at the specified pixel coordinates. Only supports types that resolve to a 
284  * sinlge number: complex etc. result in a fatal error.
285  *
286  */
287 #define IM_R_PIX_GET(_im, _i, _j, _gl) \
288         switch ((_im)->vtype) \
289         {\
290              case char_v: (_gl)       = (char) IM_R_CHAR((_im),(_i),(_j)); \
291                           break;\
292              case uchar_v: (_gl)      = (unsigned char) IM_R_UCHAR((_im),(_i),(_j)); \
293                           break;\
294              case short_v: (_gl)      = (short) IM_R_SHORT((_im),(_i),(_j)); \
295                           break;\
296              case ushort_v: (_gl)     = (unsigned short) IM_R_USHORT((_im),(_i),(_j)); \
297                           break;\
298              case int_v: (_gl)        = (int) IM_R_INT((_im),(_i),(_j)); \
299                           break;\
300              case uint_v: (_gl)       = (unsigned int) IM_R_UINT((_im),(_i),(_j)); \
301                           break;\
302              case float_v: (_gl)      = (float) IM_R_FLOAT((_im),(_i),(_j)); \
303                           break;\
304              case double_v: (_gl)     = (double) IM_R_DOUBLE((_im),(_i),(_j)); \
305                           break;\
306              default:\
307                           (_gl) = 0;\
308                           error ("IM_R_PIX_GET: unknown pixel type", fatal);\
309                           break;\
310         }
311 
312 
313 /**
314  * @brief Macro to read image green pixel data
315  * @param _im The image to read data from.
316  * @param _i The row number of the pixel.
317  * @params _j The column number of the pixel.
318  * @param _gl Pixel green value at the desired coordinates.
319  *
320  * This macro wraps the variable-type specific macros to access image red pixel values, calling 
321  * the correct one on the basis of the variable type of the input image.  It returns the red value 
322  * held in the image at the specified pixel coordinates. Only supports types that resolve to a 
323  * sinlge number: complex etc. result in a fatal error.
324  *
325  */
326 #define IM_G_PIX_GET(_im, _i, _j, _gl) \
327         switch ((_im)->vtype) \
328         {\
329              case char_v: (_gl)       = (char) IM_G_CHAR((_im),(_i),(_j)); \
330                           break;\
331              case uchar_v: (_gl)      = (unsigned char) IM_G_UCHAR((_im),(_i),(_j)); \
332                           break;\
333              case short_v: (_gl)      = (short) IM_G_SHORT((_im),(_i),(_j)); \
334                           break;\
335              case ushort_v: (_gl)     = (unsigned short) IM_G_USHORT((_im),(_i),(_j)); \
336                           break;\
337              case int_v: (_gl)        = (int) IM_G_INT((_im),(_i),(_j)); \
338                           break;\
339              case uint_v: (_gl)       = (unsigned int) IM_G_UINT((_im),(_i),(_j)); \
340                           break;\
341              case float_v: (_gl)      = (float) IM_G_FLOAT((_im),(_i),(_j)); \
342                           break;\
343              case double_v: (_gl)     = (double) IM_G_DOUBLE((_im),(_i),(_j)); \
344                           break;\
345              default:\
346                           (_gl) = 0;\
347                           error ("IM_G_PIX_GET: unknown pixel type", fatal);\
348                           break;\
349         }
350 
351 
352 /**
353  * @brief Macro to read image pixel blue data
354  * @param _im The image to read data from.
355  * @param _i The row number of the pixel.
356  * @params _j The column number of the pixel.
357  * @param _gl Pixel blue value at the desired coordinates.
358  *
359  * This macro wraps the variable-type specific macros to access image red pixel values, calling 
360  * the correct one on the basis of the variable type of the input image.  It returns the red value 
361  * held in the image at the specified pixel coordinates. Only supports types that resolve to a 
362  * sinlge number: complex etc. result in a fatal error.
363  *
364  */
365 #define IM_B_PIX_GET(_im, _i, _j, _gl) \
366         switch ((_im)->vtype) \
367         {\
368              case char_v: (_gl)       = (char) IM_B_CHAR((_im),(_i),(_j)); \
369                           break;\
370              case uchar_v: (_gl)      = (unsigned char) IM_B_UCHAR((_im),(_i),(_j)); \
371                           break;\
372              case short_v: (_gl)      = (short) IM_B_SHORT((_im),(_i),(_j)); \
373                           break;\
374              case ushort_v: (_gl)     = (unsigned short) IM_B_USHORT((_im),(_i),(_j)); \
375                           break;\
376              case int_v: (_gl)        = (int) IM_B_INT((_im),(_i),(_j)); \
377                           break;\
378              case uint_v: (_gl)       = (unsigned int) IM_B_UINT((_im),(_i),(_j)); \
379                           break;\
380              case float_v: (_gl)      = (float) IM_B_FLOAT((_im),(_i),(_j)); \
381                           break;\
382              case double_v: (_gl)     = (double) IM_B_DOUBLE((_im),(_i),(_j)); \
383                           break;\
384              default:\
385                           (_gl) = 0;\
386                           error ("IM_B_PIX_GET: unknown pixel type", fatal);\
387                           break;\
388         }
389 
390 
391 /**
392  * @brief Macro to read image pixel pointers.
393  * @param _im The image to read data from.
394  * @param _i The row number of the pixel.
395  * @params _j The column number of the pixel.
396  * @param _gl Pointer to the desired pixel.
397  * 
398  * This macro wraps the variable-type specific macros to get image pixel values, calling the 
399  * correct one on the basis of the variable type of the input image.  It returns a pointer to 
400  * the pixel of the input image at the specified pixel coordinates.
401  */
402 #define IM_PIX_GETP(_im,_i,_j,_ptr) \
403         switch ((_im)->vtype) \
404         {\
405              case char_v: (_ptr)    = &IM_CHAR((_im),(_i),(_j)); \
406                           break;\
407              case uchar_v: (_ptr)   = &IM_UCHAR((_im),(_i),(_j)); \
408                           break;\
409              case short_v: (_ptr)   = &IM_SHORT((_im),(_i),(_j)); \
410                           break;\
411              case ushort_v: (_ptr)  = &IM_USHORT((_im),(_i),(_j)); \
412                           break;\
413              case int_v: (_ptr)     = &IM_INT((_im),(_i),(_j)); \
414                           break;\
415              case uint_v: (_ptr)    = &IM_UINT((_im),(_i),(_j)); \
416                           break;\
417              case float_v: (_ptr)   = &IM_FLOAT((_im),(_i),(_j)); \
418                           break;\
419              case double_v: (_ptr)  = &IM_DOUBLE((_im),(_i),(_j)); \
420                           break;\
421              case ptr_v: (_ptr)     = IM_PTR((_im),(_i),(_j)); \
422                           break;\
423              case complex_v: (_ptr) = &IM_COMPLEX((_im),(_i),(_j)); \
424                           break;\
425              default:    (_ptr) = 0;\
426                           error ("IM_PIX_GETP: unknown pixel type", fatal);\
427                           break;\
428         }
429 
430 
431 /**
432  * @brief Macro to read image pixel red pointers.
433  * @param _im The image to read data from.
434  * @param _i The row number of the pixel.
435  * @params _j The column number of the pixel.
436  * @param _gl Pointer to the desired red pixel.
437  * 
438  * This macro wraps the variable-type specific macros to get image pixel red values, calling the 
439  * correct one on the basis of the variable type of the input image.  It returns a pointer to 
440  * the red pixel of the input image at the specified pixel coordinates.
441  */
442 #define IM_R_PIX_GETP(_im,_i,_j,_ptr) \
443         switch ((_im)->vtype) \
444         {\
445              case char_v: (_ptr)    = &IM_R_CHAR((_im),(_i),(_j)); \
446                           break;\
447              case uchar_v: (_ptr)   = &IM_R_UCHAR((_im),(_i),(_j)); \
448                           break;\
449              case short_v: (_ptr)   = &IM_R_SHORT((_im),(_i),(_j)); \
450                           break;\
451              case ushort_v: (_ptr)  = &IM_R_USHORT((_im),(_i),(_j)); \
452                           break;\
453              case int_v: (_ptr)     = &IM_R_INT((_im),(_i),(_j)); \
454                           break;\
455              case uint_v: (_ptr)    = &IM_R_UINT((_im),(_i),(_j)); \
456                           break;\
457              case float_v: (_ptr)   = &IM_R_FLOAT((_im),(_i),(_j)); \
458                           break;\
459              case double_v: (_ptr)  = &IM_R_DOUBLE((_im),(_i),(_j)); \
460                           break;\
461              default:    (_ptr) = 0;\
462                           error ("IM_R_PIX_GETP: unknown pixel type", fatal);\
463                           break;\
464         }
465 
466 /**
467  * @brief Macro to read image pixel green pointers.
468  * @param _im The image to read data from.
469  * @param _i The row number of the pixel.
470  * @params _j The column number of the pixel.
471  * @param _gl Pointer to the desired greenpixel.
472  * 
473  * This macro wraps the variable-type specific macros to get image pixel green values, calling the 
474  * correct one on the basis of the variable type of the input image.  It returns a pointer to 
475  * the green pixel of the input image at the specified pixel coordinates.
476  */
477 #define IM_G_PIX_GETP(_im,_i,_j,_ptr) \
478         switch ((_im)->vtype) \
479         {\
480              case char_v: (_ptr)    = &IM_G_CHAR((_im),(_i),(_j)); \
481                           break;\
482              case uchar_v: (_ptr)   = &IM_G_UCHAR((_im),(_i),(_j)); \
483                           break;\
484              case short_v: (_ptr)   = &IM_G_SHORT((_im),(_i),(_j)); \
485                           break;\
486              case ushort_v: (_ptr)  = &IM_G_USHORT((_im),(_i),(_j)); \
487                           break;\
488              case int_v: (_ptr)     = &IM_G_INT((_im),(_i),(_j)); \
489                           break;\
490              case uint_v: (_ptr)    = &IM_G_UINT((_im),(_i),(_j)); \
491                           break;\
492              case float_v: (_ptr)   = &IM_G_FLOAT((_im),(_i),(_j)); \
493                           break;\
494              case double_v: (_ptr)  = &IM_G_DOUBLE((_im),(_i),(_j)); \
495                           break;\
496              default:    (_ptr) = 0;\
497                           error ("IM_G_PIX_GETP: unknown pixel type", fatal);\
498                           break;\
499         }
500 
501 /**
502  * @brief Macro to read image pixel blue pointers.
503  * @param _im The image to read data from.
504  * @param _i The row number of the pixel.
505  * @params _j The column number of the pixel.
506  * @param _gl Pointer to the desired blue pixel.
507  * 
508  * This macro wraps the variable-type specific macros to get image pixel bluevalues, calling the 
509  * correct one on the basis of the variable type of the input image.  It returns a pointer to 
510  * the blue pixel of the input image at the specified pixel coordinates.
511  */
512 #define IM_B_PIX_GETP(_im,_i,_j,_ptr) \
513         switch ((_im)->vtype) \
514         {\
515              case char_v: (_ptr)    = &IM_B_CHAR((_im),(_i),(_j)); \
516                           break;\
517              case uchar_v: (_ptr)   = &IM_B_UCHAR((_im),(_i),(_j)); \
518                           break;\
519              case short_v: (_ptr)   = &IM_B_SHORT((_im),(_i),(_j)); \
520                           break;\
521              case ushort_v: (_ptr)  = &IM_B_USHORT((_im),(_i),(_j)); \
522                           break;\
523              case int_v: (_ptr)     = &IM_B_INT((_im),(_i),(_j)); \
524                           break;\
525              case uint_v: (_ptr)    = &IM_B_UINT((_im),(_i),(_j)); \
526                           break;\
527              case float_v: (_ptr)   = &IM_B_FLOAT((_im),(_i),(_j)); \
528                           break;\
529              case double_v: (_ptr)  = &IM_B_DOUBLE((_im),(_i),(_j)); \
530                           break;\
531              default:    (_ptr) = 0;\
532                           error ("IM_B_PIX_GETP: unknown pixel type", fatal);\
533                           break;\
534         }
535 
536 
537 /**
538  * @brief Macro to read image pixels as complex numbers.
539  * @param _im The image to read data from.
540  * @param _i The row number of the pixel.
541  * @params _j The column number of the pixel.
542  * @param _gl Complex pixel value at the desired coordinates.
543  * 
544  * This macro extracts the pixel at coordinates i,j from the input image as a complex number.
545  * For complex images, the complex number is returned: for other image types, the pixel value 
546  * is treated as the real part of the complex number, and the imaginary part is set to zero.
547  */
548 #define IM_PIX_GETZ(_im, _i, _j, _gl) \
549     {\
550         if ((_im)->vtype == complex_v)\
551             (_gl) = IM_COMPLEX((_im), (_i), (_j));\
552         else\
553         {\
554             IM_PIX_GET((_im), (_i), (_j), (_gl).x);\
555             (_gl).y = 0.0;\
556         }\
557     }
558 
559 
560 /**
561  * @brief Macro to set image pixel data.
562  * @param _im The image to write data to.
563  * @param _i The row number of the pixel.
564  * @params _j The column number of the pixel.
565  * @param _gl The pixel value to set.
566  * 
567  * This macro wraps the variable-type specific macros to access image pixel values, calling the 
568  * correct one on the basis of the variable type of the input image.  It sets the value of the 
569  * pixel at the specified coordinates i,j to the value held in _gl. For complex images, only the 
570  * real part of the complex number is set: use IM_PIX_SETZ to set the whole complex number.   
571  * 
572  * PAB 05/12/2008: The operation is undefined for pointer images and results in a fatal error: use
573  * IM_PTR instead.
574  */
575 #define IM_PIX_SET(_im,_i,_j,_gl) \
576         switch ((_im)->vtype) \
577         {\
578              case char_v: IM_CHAR((_im),(_i),(_j)) = (char) (_gl); \
579                           break;\
580              case uchar_v: IM_UCHAR((_im),(_i),(_j)) = (unsigned char) (_gl); \
581                           break;\
582              case short_v: IM_SHORT((_im),(_i),(_j)) = (short) (_gl); \
583                           break;\
584              case ushort_v: IM_USHORT((_im),(_i),(_j)) = (unsigned short) (_gl); \
585                           break;\
586              case int_v: IM_INT((_im),(_i),(_j)) = (int) (_gl); \
587                           break;\
588              case uint_v: IM_UINT((_im),(_i),(_j)) = (unsigned int) (_gl); \
589                           break;\
590              case float_v: IM_FLOAT((_im),(_i),(_j)) = (float) (_gl); \
591                           break;\
592              case double_v: IM_DOUBLE((_im),(_i),(_j)) = (double) (_gl); \
593                           break;\
594              case complex_v: IM_COMPLEX((_im),(_i),(_j)).x = (double) (_gl); \
595                           break;\
596              case ptr_v:  error ("IM_PIX_SET not implemented for pointer images: use IM_PTR instead\n", fatal);\
597                           break;\
598              case vram0_v: IM_VRAM0((_im),(_i),(_j)) = (unsigned char)(_gl); \
599                           break;\
600              case vram1_v: IM_VRAM1((_im),(_i),(_j)) = (unsigned char)(_gl); \
601                           break;\
602              case vram2_v: IM_VRAM2((_im),(_i),(_j)) = (unsigned char)(_gl); \
603                           break;\
604              case vram3_v: IM_VRAM3((_im),(_i),(_j)) = (unsigned char)(_gl); \
605                           break;\
606              default:     error ("IM_PIX_SET: unknown pixel type", fatal);\
607                           break;\
608         }
609 
610 
611 /**
612  * @brief Macro to set image pixel red data.
613  * @param _im The image to write data to.
614  * @param _i The row number of the pixel.
615  * @params _j The column number of the pixel.
616  * @param _gl The pixel red value to set.
617  * 
618  * This macro wraps the variable-type specific macros to access image pixel red values, calling the 
619  * correct one on the basis of the variable type of the input image.  It sets the red value of the 
620  * pixel at the specified coordinates i,j to the value held in _gl. 
621  *
622  */
623 #define IM_R_PIX_SET(_im,_i,_j,_gl) \
624         switch ((_im)->vtype) \
625         {\
626              case char_v: IM_R_CHAR((_im),(_i),(_j)) = (char) (_gl); \
627                           break;\
628              case uchar_v: IM_R_UCHAR((_im),(_i),(_j)) = (unsigned char) (_gl); \
629                           break;\
630              case short_v: IM_R_SHORT((_im),(_i),(_j)) = (short) (_gl); \
631                           break;\
632              case ushort_v: IM_R_USHORT((_im),(_i),(_j)) = (unsigned short) (_gl); \
633                           break;\
634              case int_v: IM_R_INT((_im),(_i),(_j)) = (int) (_gl); \
635                           break;\
636              case uint_v: IM_R_UINT((_im),(_i),(_j)) = (unsigned int) (_gl); \
637                           break;\
638              case float_v: IM_R_FLOAT((_im),(_i),(_j)) = (float) (_gl); \
639                           break;\
640              case double_v: IM_R_DOUBLE((_im),(_i),(_j)) = (double) (_gl); \
641                           break;\
642              default:     error ("IM_R_PIX_SET: unknown pixel type", fatal);\
643                           break;\
644         }
645 
646 
647 /**
648  * @brief Macro to set image pixel green data.
649  * @param _im The image to write data to.
650  * @param _i The row number of the pixel.
651  * @params _j The column number of the pixel.
652  * @param _gl The pixel green value to set.
653  * 
654  * This macro wraps the variable-type specific macros to access image pixel green values, calling the 
655  * correct one on the basis of the variable type of the input image.  It sets the green value of the 
656  * pixel at the specified coordinates i,j to the value held in _gl.
657  *
658  */
659 #define IM_G_PIX_SET(_im,_i,_j,_gl) \
660         switch ((_im)->vtype) \
661         {\
662              case char_v: IM_G_CHAR((_im),(_i),(_j)) = (char) (_gl); \
663                           break;\
664              case uchar_v: IM_G_UCHAR((_im),(_i),(_j)) = (unsigned char) (_gl); \
665                           break;\
666              case short_v: IM_G_SHORT((_im),(_i),(_j)) = (short) (_gl); \
667                           break;\
668              case ushort_v: IM_G_USHORT((_im),(_i),(_j)) = (unsigned short) (_gl); \
669                           break;\
670              case int_v: IM_G_INT((_im),(_i),(_j)) = (int) (_gl); \
671                           break;\
672              case uint_v: IM_G_UINT((_im),(_i),(_j)) = (unsigned int) (_gl); \
673                           break;\
674              case float_v: IM_G_FLOAT((_im),(_i),(_j)) = (float) (_gl); \
675                           break;\
676              case double_v: IM_G_DOUBLE((_im),(_i),(_j)) = (double) (_gl); \
677                           break;\
678              default:     error ("IM_G_PIX_SET: unknown pixel type", fatal);\
679                           break;\
680         }
681 
682 
683 /**
684  * @brief Macro to set image pixel blue data.
685  * @param _im The image to write data to.
686  * @param _i The row number of the pixel.
687  * @params _j The column number of the pixel.
688  * @param _gl The pixel blue value to set.
689  * 
690  * This macro wraps the variable-type specific macros to access image pixel blue values, calling the 
691  * correct one on the basis of the variable type of the input image.  It sets the blue value of the 
692  * pixel at the specified coordinates i,j to the value held in _gl.
693  *
694  */
695 #define IM_B_PIX_SET(_im,_i,_j,_gl) \
696         switch ((_im)->vtype) \
697         {\
698              case char_v: IM_B_CHAR((_im),(_i),(_j)) = (char) (_gl); \
699                           break;\
700              case uchar_v: IM_B_UCHAR((_im),(_i),(_j)) = (unsigned char) (_gl); \
701                           break;\
702              case short_v: IM_B_SHORT((_im),(_i),(_j)) = (short) (_gl); \
703                           break;\
704              case ushort_v: IM_B_USHORT((_im),(_i),(_j)) = (unsigned short) (_gl); \
705                           break;\
706              case int_v: IM_B_INT((_im),(_i),(_j)) = (int) (_gl); \
707                           break;\
708              case uint_v: IM_B_UINT((_im),(_i),(_j)) = (unsigned int) (_gl); \
709                           break;\
710              case float_v: IM_B_FLOAT((_im),(_i),(_j)) = (float) (_gl); \
711                           break;\
712              case double_v: IM_B_DOUBLE((_im),(_i),(_j)) = (double) (_gl); \
713                           break;\
714              default:     error ("IM_B_PIX_SET: unknown pixel type", fatal);\
715                           break;\
716         }
717 
718 
719 /**
720  * @brief Macro to set complex image pixel data.
721  * @param _im The image to write data to.
722  * @param _i The row number of the pixel.
723  * @params _j The column number of the pixel.
724  * @param _gl The complex pixel value to set.
725  * 
726  * This macro sets the value of the pixel at the specified coordinates i,j to the complex number 
727  * held in _gl. For complex images, both real and imaginary part are set. For other image types, 
728  * the pixel value is set to the real part of the complex number.
729  */
730 #define IM_PIX_SETZ(_im, _i, _j, _gl) \
731     {\
732         if ((_im)->vtype == complex_v)\
733             IM_COMPLEX((_im), (_i), (_j)) = (_gl);\
734         else\
735             IM_PIX_SET((_im), (_i), (_j), (_gl).x);\
736     }
737 
738 /**
739  * @brief Macro to access a row of an image.
740  * @param _im The image to access.
741  * @param _i The coordinate of the row to access.
742  *
743  * This macro accesses row _i of image _im.
744  */
745 #define IM_ROW(_im, _i) (((void **)(_im)->data)[(_i)])
746 
747 
748 /**
749  * @brief Macro to access a row of red values of an image.
750  * @param _im The image to access.
751  * @param _i The coordinate of the row to access.
752  *
753  * This macro accesses row _i of rdata of image _im.
754  */
755 #define IM_R_ROW(_im, _i) (((void **)(_im)->rdata)[(_i)])
756 
757 /**
758  * @brief Macro to access a row of green values of an image.
759  * @param _im The image to access.
760  * @param _i The coordinate of the row to access.
761  *
762  * This macro accesses row _i of gdata of image _im.
763  */
764 #define IM_G_ROW(_im, _i) (((void **)(_im)->gdata)[(_i)])
765 
766 /**
767  * @brief Macro to access a row of blue values of an image.
768  * @param _im The image to access.
769  * @param _i The coordinate of the row to access.
770  *
771  * This macro accesses row _i of bdata of image _im.
772  */
773 #define IM_B_ROW(_im, _i) (((void **)(_im)->bdata)[(_i)])
774 
775 
776 /**
777  * @brief Macro to get a pointer to a row in an image.
778  * @param _im Image to enter the row into.
779  * @param _i The coordinate of the desired row.
780  * @param _row Pointer to the desired row.
781  *
782  * This macro sets _row to point to row _i of image _im.
783  */
784 #define IM_ROW_GET(_im, _i, _row) _row = IM_ROW(_im, _i);
785 
786 
787 /**
788  * @brief Macro to get a pointer to a red row in an image.
789  * @param _im Image to enter the row into.
790  * @param _i The coordinate of the desired row.
791  * @param _row Pointer to the desired red row.
792  *
793  * This macro sets _row to point to row _i of rdata of image _im.
794  */
795 #define IM_R_ROW_GET(_im, _i, _row) _row = IM_R_ROW(_im, _i);
796 
797 /**
798  * @brief Macro to get a pointer to a green row in an image.
799  * @param _im Image to enter the row into.
800  * @param _i The coordinate of the desired row.
801  * @param _row Pointer to the desired green row.
802  *
803  * This macro sets _row to point to row _i of gdata of image _im.
804  */
805 #define IM_G_ROW_GET(_im, _i, _row) _row = IM_G_ROW(_im, _i);
806 
807 /**
808  * @brief Macro to get a pointer to a blue row in an image.
809  * @param _im Image to enter the row into.
810  * @param _i The coordinate of the desired row.
811  * @param _row Pointer to the desired blue row.
812  *
813  * This macro sets _row to point to row _i of bdata of image _im.
814  */
815 #define IM_B_ROW_GET(_im, _i, _row) _row = IM_B_ROW(_im, _i);
816 
817 
818 /**
819  * @brief Macro to set a pointer to a row in an image.
820  * @param _im  The image in which to set the row.
821  * @param _i The coordinate of the row to replace.
822  * @param _row Pointer to the row to be entered into the image.
823  *
824  * This macro sets the pointer of row _i in image _im to _row. Image rows are void pointers.
825  */
826 #define IM_ROW_SET(_im, _i ,_row) IM_ROW(_im, _i) = _row;
827 
828 
829 /**
830  * @brief Macro to set a pointer to a red row in an image.
831  * @param _im  The image in which to set the row.
832  * @param _i The coordinate of the row to replace.
833  * @param _row Pointer to the red row to be entered into the image.
834  *
835  * This macro sets the pointer of row _i in rdata of image _im to _row. Image rows are void pointers.
836  */
837 #define IM_R_ROW_SET(_im, _i ,_row) IM_R_ROW(_im, _i) = _row;
838 
839 
840 /**
841  * @brief Macro to set a pointer to a green row in an image.
842  * @param _im  The image in which to set the row.
843  * @param _i The coordinate of the row to replace.
844  * @param _row Pointer to the green row to be entered into the image.
845  *
846  * This macro sets the pointer of row _i in gdata of image _im to _row. Image rows are void pointers.
847  */
848 #define IM_G_ROW_SET(_im, _i ,_row) IM_G_ROW(_im, _i) = _row;
849 
850 
851 /**
852  * @brief Macro to set a pointer to a blue row in an image.
853  * @param _im  The image in which to set the row.
854  * @param _i The coordinate of the row to replace.
855  * @param _row Pointer to the blue row to be entered into the image.
856  *
857  * This macro sets the pointer of row _i in bdata of image _im to _row. Image rows are void pointers.
858  */
859 #define IM_B_ROW_SET(_im, _i ,_row) IM_B_ROW(_im, _i) = _row;
860 
861 
862 /**
863  * @brief Macro to loop over a region. 
864  * @param _roi The region over which to loop.
865  * @param _row The loop variable for the region row coordinates.
866  * @param _col The loop variable for the region column coordinates.
867  *
868  * This macro performs a loop over the coordinates within a region, using the loop variable 
869  * _row to loop from ly to uy and the loop variable _col to loop from lx to ux, where  these 
870  * extents are obtained from the imregion structure _roi.
871  */
872 #define FOR_IM(_roi,_row,_col) for ((_row)=(_roi)->ly; (_row)<(_roi)->uy; (_row)++) \
873                                  for ((_col)=(_roi)->lx; (_col)<(_roi)->ux; (_col)++)
874 
875 #endif  /* TINA_IMG_GEN_DEF_HDR */
876 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.