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

Linux Cross Reference
Tina4/src/vision/improc/im_window.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/visionfuncs.h>
  8  
  9 Imrect *imi_window(Imrect *im1, double thresh, double constant)
 10 {
 11     Imrect *im2;
 12     Imregion *roi;
 13     int *row1, *row2;
 14     int lx, ux, ly, uy;
 15     int i, j;
 16  
 17     if (im1 == NULL)
 18         return (NULL);
 19  
 20     roi = im1->region;
 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     im2 = im_alloc(im1->height, im1->width, roi, int_v);
 29     row1 = ivector_alloc(lx, ux);
 30     row2 = ivector_alloc(lx, ux);
 31  
 32     for (i = ly; i < uy; ++i)
 33     {
 34         im_get_row(row1, im1, i, lx, ux);
 35         for (j = lx; j < ux; ++j)
 36             if(row1[j] < thresh)
 37                 row2[j] = (int)thresh;
 38             else if (row1[j] > thresh+constant)
 39                 row2[j] = (int)(thresh+constant);
 40             else
 41                 row2[j] = row1[j];
 42         im_put_row(row2, im2, i, lx, ux);
 43     }
 44  
 45     ivector_free(row1, lx);
 46     ivector_free(row2, lx);
 47     return (im2);
 48 }
 49 
 50 Imrect *imf_window(Imrect *im1, double thresh, double constant)
 51 {
 52     Imrect *im2;
 53     Imregion *roi;
 54     float *row1, *row2;
 55     int lx, ux, ly, uy;
 56     int i, j;
 57  
 58     if (im1 == NULL)
 59         return (NULL);
 60  
 61     roi = im1->region;
 62     if (roi == NULL)
 63         return (NULL);
 64     lx = roi->lx;
 65     ux = roi->ux;
 66     ly = roi->ly;
 67     uy = roi->uy;
 68  
 69     im2 = im_alloc(im1->height, im1->width, roi, float_v);
 70     row1 = fvector_alloc(lx, ux);
 71     row2 = fvector_alloc(lx, ux);
 72  
 73     for (i = ly; i < uy; ++i)
 74     {
 75         im_get_rowf(row1, im1, i, lx, ux);
 76         for (j = lx; j < ux; ++j)
 77             if(row1[j] < thresh)
 78                 row2[j] = (float)thresh;
 79             else if (row1[j] > thresh+constant)
 80                 row2[j] = (float)(thresh+constant);
 81             else
 82                 row2[j] = row1[j];
 83 
 84         im_put_rowf(row2, im2, i, lx, ux);
 85     }
 86  
 87     fvector_free(row1, lx);
 88     fvector_free(row2, lx);
 89     return (im2);
 90 }
 91 
 92 
 93 Imrect *im_window(Imrect *im, double thresh,double constant)
 94 {
 95     if(im == NULL )
 96         return(NULL);
 97     switch(im->vtype)
 98     {
 99         case uchar_v:
100         case char_v:
101         case short_v:
102         case ushort_v:
103         case int_v:
104             return(imi_window(im,thresh,constant));
105         case float_v:
106             return(imf_window(im,thresh,constant));
107         case complex_v:
108         default:
109             return(NULL);
110     }
111 }
112 
113 

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