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

Linux Cross Reference
Tina4/src/vision/improc/im_hist.c

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

  1 #include <math.h>
  2 #include <tina/sys.h>
  3 #include <tina/sysfuncs.h>
  4 #include <tina/math.h>
  5 #include <tina/mathfuncs.h>
  6 #include <tina/vision.h>
  7 #include <tina/hist_funcs.h>
  8 
  9 Imrect *imc_hist(shistogram **imhist, double k, double range,
 10                  Imrect *im, Imregion *roi)
 11 {
 12     Imrect *im2;
 13     int *row1, *row2;
 14     int lx, ux, ly, uy;
 15     int width, height;
 16     int i, j, ndata;
 17 
 18     if (im == NULL)
 19         return (NULL);
 20 
 21     if (roi == NULL)
 22         return (NULL);
 23     lx = roi->lx;
 24     ux = roi->ux;
 25     ly = roi->ly;
 26     uy = roi->uy;
 27 
 28     width = im->width;
 29     height = im->height;
 30 
 31     im2 = im_alloc(height, width, im->region, char_v);
 32     if (*imhist ==NULL)
 33        *imhist = hbook1(0,"image contents\0",(float)(k - range),
 34                     (float)(k + range), 100);
 35     
 36     row1 = ivector_alloc(lx, ux);
 37 
 38     for (i = ly; i < uy; ++i)
 39     {
 40         im_get_row(row1, im, i, lx, ux);
 41         for (j = lx; j < ux; ++j)
 42         {
 43             if (row1[j]!=0.0) hfill1s(*imhist,(float)row1[j],1.0);
 44         }
 45     }
 46 
 47     ivector_free(row1, lx);
 48     roi = im->region;
 49     lx = roi->lx;
 50     ux = roi->ux;
 51     ly = roi->ly;
 52     uy = roi->uy;
 53     row1 = ivector_alloc(lx, ux);
 54     row2 = ivector_alloc(lx, ux);
 55     for (i = ly; i < uy; ++i)
 56     {
 57         im_get_row(row1, im, i, lx, ux);
 58         for (j = lx; j < ux; ++j)
 59         {
 60             row2[j] =   hfill1s(*imhist,(float)row1[j],0.0);
 61         }
 62         im_put_row(row2, im2, i, lx, ux);
 63     }
 64 
 65     ivector_free(row1, lx);
 66     ivector_free(row2, lx);
 67     return (im2);
 68 }
 69 
 70 Imrect *imi_hist(shistogram **imhist, double k, double range,
 71                  Imrect *im, Imregion *roi)
 72 {
 73     Imrect *im2;
 74     int *row1, *row2;
 75     int lx, ux, ly, uy;
 76     int width, height;
 77     int i, j, ndata;
 78  
 79     if (im == NULL)
 80         return (NULL);
 81  
 82     if (roi == NULL)
 83         return (NULL);
 84     lx = roi->lx;
 85     ux = roi->ux;
 86     ly = roi->ly;
 87     uy = roi->uy;
 88  
 89     width = im->width;
 90     height = im->height;
 91  
 92     im2 = im_alloc(height, width, im->region, int_v);
 93     if (*imhist ==NULL)
 94          *imhist = hbook1(0,"image contents\0",(float)(k - range),
 95                     (float)(k + range), 100);
 96  
 97     row1 = ivector_alloc(lx, ux);
 98  
 99     for (i = ly; i < uy; ++i)
100     {
101         im_get_row(row1, im, i, lx, ux);
102         for (j = lx; j < ux; ++j)
103         {
104               if (row1[j] !=0.0) hfill1s(*imhist,(float)row1[j],1.0);
105         }
106     }
107  
108     ivector_free(row1, lx);
109     roi = im->region;
110     lx = roi->lx;
111     ux = roi->ux;
112     ly = roi->ly;
113     uy = roi->uy;
114     row1 = ivector_alloc(lx, ux);
115     row2 = ivector_alloc(lx, ux);
116     for (i = ly; i < uy; ++i)
117     {
118         im_get_row(row1, im, i, lx, ux);
119         for (j = lx; j < ux; ++j)
120         {
121             row2[j] =   hfill1s(*imhist,(float)row1[j],0.0);
122         }
123         im_put_row(row2, im2, i, lx, ux);
124     }
125  
126     ivector_free(row1, lx);
127     ivector_free(row2, lx);
128     return (im2);
129 }
130 
131 Imrect *imf_hist(shistogram **imhist, double k, double range,
132                  Imrect *im, Imregion *roi)
133 {
134     Imrect *im2;
135     float *row1, *row2;
136     int lx, ux, ly, uy;
137     int width, height;
138     int i, j, ndata;
139  
140     if (im == NULL)
141         return (NULL);
142  
143     if (roi == NULL)
144         return (NULL);
145     lx = roi->lx;
146     ux = roi->ux;
147     ly = roi->ly;
148     uy = roi->uy;
149  
150     width = im->width;
151     height = im->height;
152  
153     im2 = im_alloc(height, width, im->region, float_v);
154     if (*imhist==NULL)
155         *imhist = hbook1(0,"image contents\0",(float)(k - range),
156                     (float)(k + range), 100);
157  
158     row1 = fvector_alloc(lx, ux);
159  
160     for (i = ly; i < uy; ++i)
161     {
162         im_get_rowf(row1, im, i, lx, ux);
163         for (j = lx; j < ux; ++j)
164         {
165             if(row1[j]!=0.0) hfill1s(*imhist,(float)row1[j],1.0);
166         }
167     }
168  
169     fvector_free(row1, lx);
170     roi = im->region;
171     lx = roi->lx;
172     ux = roi->ux;
173     ly = roi->ly;
174     uy = roi->uy;
175     row1 = fvector_alloc(lx, ux);
176     row2 = fvector_alloc(lx, ux);
177     for (i = ly; i < uy; ++i)
178     {
179         im_get_rowf(row1, im, i, lx, ux);
180         for (j = lx; j < ux; ++j)
181         {
182             row2[j] =  hfill1s(*imhist,(float)row1[j],0.0);
183         }
184         im_put_rowf(row2, im2, i, lx, ux);
185     }
186  
187     fvector_free(row1, lx);
188     fvector_free(row2, lx);
189     return (im2);
190 }
191 
192 
193 Imrect *im_hist(shistogram **imhist, double k, double range,
194                 Imrect *im, Imregion *roi)
195 {
196     if(im == NULL )
197         return(NULL);
198     switch(im->vtype)
199     {
200         case uchar_v:
201         case char_v:
202             return(imc_hist(imhist,k,range,im,roi));
203         case short_v:
204         case ushort_v:
205         case int_v:
206             return(imi_hist(imhist,k,range,im,roi));
207         case float_v:
208             return(imf_hist(imhist,k,range,im,roi));
209         default:
210             return(NULL);
211     }
212 }
213 

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