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

Linux Cross Reference
Tina4/src/math/vector/vec_image.c

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

  1 /**@(#)Extracting data from image row or col in vector format
  2  */
  3 
  4 #include <stdio.h>
  5 #include <math.h>
  6 #include <tina/sys.h>
  7 #include <tina/sysfuncs.h>
  8 #include <tina/math.h>
  9 #include <tina/mathfuncs.h>
 10 
 11 /* return vector of data in row y from lx to ux, cast to vtype */
 12 Vector *im_row_vector(Imrect * im, int y, int lx, int ux, Vartype vtype)
 13 {
 14     int     x, xmin, xmax;
 15     Vector *v = vector_alloc(ux - lx, vtype);
 16 
 17     if (v == NULL)
 18         return (NULL);
 19     if (im == NULL || y < im->region->ly || y >= im->region->uy)
 20         return (v);
 21 
 22     xmin = MAX(lx, im->region->lx);
 23     xmax = MIN(ux, im->region->ux);
 24     switch (vtype)
 25     {
 26     case char_v:
 27     case uchar_v:
 28     case short_v:
 29     case ushort_v:
 30     case int_v:
 31     case uint_v:
 32         {
 33             for (x = xmin; x < xmax; x++)
 34             {
 35                 double     gl;
 36 
 37                 IM_PIX_GET(im, y, x, gl);
 38                 VECTOR_SET(v, x - lx, gl);
 39             }
 40             break;
 41         }
 42     case float_v:
 43     case double_v:
 44         {
 45             for (x = xmin; x < xmax; x++)
 46             {
 47                 double  gl;
 48 
 49                 IM_PIX_GET(im, y, x, gl);
 50                 VECTOR_SET(v, x - lx, gl);
 51             }
 52             break;
 53         }
 54     case complex_v:
 55         {
 56             for (x = xmin; x < xmax; x++)
 57             {
 58                 Complex gl = {Complex_id};
 59 
 60                 IM_PIX_GETZ(im, y, x, gl);
 61                 VECTOR_SETZ(v, x - lx, gl);
 62             }
 63             break;
 64         }
 65     default:
 66         vector_free(v);
 67         return (NULL);
 68     }
 69 
 70     return (v);
 71 }
 72 
 73 /* return vector of data in column x from ly to uy, cast to vtype */
 74 Vector *im_col_vector(Imrect * im, int x, int ly, int uy, Vartype vtype)
 75 {
 76     int     y, ymin, ymax;
 77     Vector *v = vector_alloc(uy - ly, vtype);
 78 
 79     if (v == NULL)
 80         return (NULL);
 81     if (im == NULL || x < im->region->lx || x >= im->region->ux)
 82         return (v);
 83 
 84     ymin = MAX(ly, im->region->ly);
 85     ymax = MIN(uy, im->region->uy);
 86     switch (vtype)
 87     {
 88     case char_v:
 89     case uchar_v:
 90     case short_v:
 91     case ushort_v:
 92     case int_v:
 93     case uint_v:
 94         {
 95             for (y = ymin; y < ymax; y++)
 96             {
 97                 double     gl;
 98 
 99                 IM_PIX_GET(im, y, x, gl);
100                 VECTOR_SET(v, y - ly, gl);
101             }
102             break;
103         }
104     case float_v:
105     case double_v:
106         {
107             for (y = ymin; y < ymax; y++)
108             {
109                 double  gl;
110 
111                 IM_PIX_GET(im, y, x, gl);
112                 VECTOR_SET(v, y - ly, gl);
113             }
114             break;
115         }
116     case complex_v:
117         {
118             for (y = ymin; y < ymax; y++)
119             {
120                 Complex gl = {Complex_id};
121 
122                 IM_PIX_GETZ(im, y, x, gl);
123                 VECTOR_SETZ(v, y - ly, gl);
124             }
125             break;
126         }
127     default:
128         vector_free(v);
129         return (NULL);
130     }
131 
132     return (v);
133 }
134 

~ [ 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.