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

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

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