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

Linux Cross Reference
Tina5/tina-libs/tina/geometry/geomImg_thresh.c

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

  1 /**********
  2  * 
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU Lesser General Public License as 
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU Lesser General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU Lesser General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc., 
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  **********
 20  * 
 21  * Program :    TINA
 22  * File    :  $Source: /home/tina/cvs/tina-libs/tina/geometry/geomImg_thresh.c,v $
 23  * Date    :  $Date: 2002/12/09 11:51:23 $
 24  * Version :  $Revision: 1.1.1.1 $
 25  * CVS Id  :  $Id: geomImg_thresh.c,v 1.1.1.1 2002/12/09 11:51:23 cvstina Exp $
 26  *
 27  * Author  : Legacy TINA
 28  *
 29  * Notes :
 30  *
 31  *********
 32 */
 33 
 34 #include "geomImg_thresh.h"
 35 
 36 #if HAVE_CONFIG_H
 37   #include <config.h>
 38 #endif
 39 
 40 #include <math.h>
 41 #include <tina/sys/sysDef.h>
 42 #include <tina/sys/sysPro.h>
 43 #include <tina/math/mathDef.h>
 44 #include <tina/math/mathPro.h>
 45 #include <tina/image/imgDef.h>
 46 #include <tina/image/imgPro.h>
 47 #include <tina/geometry/geom_EdgeDef.h>
 48 
 49 Imrect *imi_thresh(double k, Imrect *im1)
 50 {
 51     Imrect *im2;
 52     Imregion *roi;
 53     int *row1, *row2;
 54     int lx, ux, ly, uy;
 55     int i, j;
 56 
 57     if (im1 == NULL)
 58         return (NULL);
 59 
 60     roi = im1->region;
 61     if (roi == NULL)
 62         return (NULL);
 63     lx = roi->lx;
 64     ux = roi->ux;
 65     ly = roi->ly;
 66     uy = roi->uy;
 67 
 68     im2 = im_alloc(im1->height, im1->width, roi, int_v);
 69     row1 = ivector_alloc(lx, ux);
 70     row2 = ivector_alloc(lx, ux);
 71 
 72     for (i = ly; i < uy; ++i)
 73     {
 74         im_get_row(row1, im1, i, lx, ux);
 75         for (j = lx; j < ux; ++j)
 76             if(row1[j] > k)
 77                 row2[j] = row1[j];
 78             else
 79                 row2[j] = (int)0.0;
 80         im_put_row(row2, im2, i, lx, ux);
 81     }
 82 
 83     ivector_free(row1, lx);
 84     ivector_free(row2, lx);
 85     return (im2);
 86 }
 87 
 88 Imrect *imi_bthresh(double k, Imrect *im1)
 89 {
 90     Imrect *im2;
 91     Imregion *roi;
 92     int *row1, *row2;
 93     int lx, ux, ly, uy;
 94     int i, j;
 95  
 96     if (im1 == NULL)
 97         return (NULL);
 98  
 99     roi = im1->region;
100     if (roi == NULL)
101         return (NULL);
102     lx = roi->lx;
103     ux = roi->ux;
104     ly = roi->ly;
105     uy = roi->uy;
106  
107     im2 = im_alloc(im1->height, im1->width, roi, int_v);
108     row1 = ivector_alloc(lx, ux);
109     row2 = ivector_alloc(lx, ux);
110  
111     for (i = ly; i < uy; ++i)
112     {
113         im_get_row(row1, im1, i, lx, ux);
114         for (j = lx; j < ux; ++j)
115             if(row1[j] > k)
116                 row2[j] = (int)1.0;
117             else
118                 row2[j] = (int)0.0;
119         im_put_row(row2, im2, i, lx, ux);
120     }
121  
122     ivector_free(row1, lx);
123     ivector_free(row2, lx);
124     return (im2);
125 }
126 
127 Imrect *imf_thresh(double k, Imrect *im1)
128 {
129     Imrect *im2;
130     Imregion *roi;
131     float *row1, *row2;
132     int lx, ux, ly, uy;
133     int i, j;
134 
135     if (im1 == NULL)
136         return (NULL);
137 
138     roi = im1->region;
139     if (roi == NULL)
140         return (NULL);
141     lx = roi->lx;
142     ux = roi->ux;
143     ly = roi->ly;
144     uy = roi->uy;
145 
146     im2 = im_alloc(im1->height, im1->width, roi, float_v);
147     row1 = fvector_alloc(lx, ux);
148     row2 = fvector_alloc(lx, ux);
149 
150     for (i = ly; i < uy; ++i)
151     {
152         im_get_rowf(row1, im1, i, lx, ux);
153         for (j = lx; j < ux; ++j)
154             if(row1[j] > k)
155                 row2[j] = row1[j];
156             else
157                 row2[j] = (float)0.0;
158         im_put_rowf(row2, im2, i, lx, ux);
159     }
160 
161     fvector_free(row1, lx);
162     fvector_free(row2, lx);
163     return (im2);
164 }
165 
166 Imrect *imf_bthresh(double k, Imrect *im1)
167 {
168     Imrect *im2;
169     Imregion *roi;
170     float *row1, *row2;
171     int lx, ux, ly, uy;
172     int i, j;
173  
174     if (im1 == NULL)
175         return (NULL);
176  
177     roi = im1->region;
178     if (roi == NULL)
179         return (NULL);
180     lx = roi->lx;
181     ux = roi->ux;
182     ly = roi->ly;
183     uy = roi->uy;
184  
185     im2 = im_alloc(im1->height, im1->width, roi, float_v);
186     row1 = fvector_alloc(lx, ux);
187     row2 = fvector_alloc(lx, ux);
188  
189     for (i = ly; i < uy; ++i)
190     {
191         im_get_rowf(row1, im1, i, lx, ux);
192         for (j = lx; j < ux; ++j)
193             if(row1[j] > k)
194                 row2[j] = (float)1.0;
195             else
196                 row2[j] = (float)0.0;
197         im_put_rowf(row2, im2, i, lx, ux);
198     }
199  
200     fvector_free(row1, lx);
201     fvector_free(row2, lx);
202     return (im2);
203 }
204 
205 Imrect *imz_thresh(double k, Imrect *im1)
206 {
207     Imrect *im2;
208     Imregion *roi;
209     Complex *row1, *row2;
210     int lx, ux, ly, uy;
211     int i, j;
212  
213     if (im1 == NULL)
214         return (NULL);
215  
216     roi = im1->region;
217     if (roi == NULL)
218         return (NULL);
219     lx = roi->lx;
220     ux = roi->ux;
221     ly = roi->ly;
222     uy = roi->uy;
223  
224     im2 = im_alloc(im1->height, im1->width, roi, float_v);
225     row1 = zvector_alloc(lx, ux);
226     row2 = zvector_alloc(lx, ux);
227  
228     for (i = ly; i < uy; ++i)
229     {
230         im_get_rowz(row1, im1, i, lx, ux);
231         for (j = lx; j < ux; ++j)
232             if(row1[j].x > k)
233             {
234                 row2[j].x = row1[j].x;
235                 row2[j].y = row1[j].y;
236             }
237             else
238             {
239                 row2[j].x = 0.0;
240                 row2[j].y = 0.0;
241             }
242         im_put_rowz(row2, im2, i, lx, ux);
243     }
244  
245     zvector_free(row1, lx);
246     zvector_free(row2, lx);
247     return (im2);
248 }
249 
250 Imrect *imz_bthresh(double k, Imrect *im1)
251 {
252     Imrect *im2;
253     Imregion *roi;
254     Complex *row1, *row2;
255     int lx, ux, ly, uy;
256     int i, j;
257  
258     if (im1 == NULL)
259         return (NULL);
260  
261     roi = im1->region;
262     if (roi == NULL)
263         return (NULL);
264     lx = roi->lx;
265     ux = roi->ux;
266     ly = roi->ly;
267     uy = roi->uy;
268  
269     im2 = im_alloc(im1->height, im1->width, roi, float_v);
270     row1 = zvector_alloc(lx, ux);
271     row2 = zvector_alloc(lx, ux);
272  
273     for (i = ly; i < uy; ++i)
274     {
275         im_get_rowz(row1, im1, i, lx, ux);
276         for (j = lx; j < ux; ++j)
277             if(row1[j].x > k)
278             {
279                 row2[j].x = 1.0;
280                 row2[j].y = 0.0;
281             }
282             else
283             {
284                 row2[j].x = 0.0;
285                 row2[j].y = 0.0;
286             }
287         im_put_rowz(row2, im2, i, lx, ux);
288     }
289  
290     zvector_free(row1, lx);
291     zvector_free(row2, lx);
292     return (im2);
293 }
294 
295 Imrect *imp_bthresh(double k, Imrect *im1)
296 {
297     Imrect *im2;
298     Imregion *roi;
299     float *row2;
300     void **row1;
301     int lx, ux, ly, uy;
302     int i, j;
303  
304     if (im1 == NULL)
305         return (NULL);
306  
307     roi = im1->region;
308     if (roi == NULL)
309         return (NULL);
310     lx = roi->lx;
311     ux = roi->ux;
312     ly = roi->ly;
313     uy = roi->uy;
314  
315     im2 = im_alloc(im1->height, im1->width, roi, float_v);
316     row2 = fvector_alloc(lx, ux);
317  
318     for (i = ly; i < uy; ++i)
319     {
320         row1 = IM_ROW(im1,i);
321         for (j = lx; j < ux; ++j)
322             if(row1[j]&&((Edgel *)row1[j])->contrast > k)
323                 row2[j] = (float)1.0;
324             else
325                 row2[j] = (float)0.0;
326         im_put_rowf(row2, im2, i, lx, ux);
327     }
328  
329     fvector_free(row2, lx);
330     return (im2);
331 }
332 
333 Imrect *im_thresh(double k,Imrect *im)
334 {
335     if(im == NULL )
336         return(NULL);
337     switch(im->vtype)
338     {
339         case uchar_v:
340         case char_v:
341         case short_v:
342         case ushort_v:
343         case int_v:
344             return(imi_thresh(k,im));
345         case float_v:
346             return(imf_thresh(k,im));
347         case complex_v:
348             return(imz_thresh(k,im));
349         default:
350             return(NULL);
351     }
352 }
353 
354 Imrect *im_bthresh(double k,Imrect *im)
355 {
356     if(im == NULL )
357         return(NULL);
358     switch(im->vtype)
359     {
360         case uchar_v:
361         case char_v:
362         case short_v:
363         case ushort_v:
364         case int_v:
365             return(imi_bthresh(k,im));
366         case float_v:
367             return(imf_bthresh(k,im));
368         case complex_v:
369             return(imz_bthresh(k,im));
370         case ptr_v:
371             return(imp_bthresh(k,im));
372         default:
373             return(NULL);
374     }
375 }
376 

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