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

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

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

  1 /**@(#)
  2 **/
  3 #include <math.h>
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 
  7 Imrect *imf_grad_h(Imrect * image)
  8 {
  9     Imrect *grad_im;
 10     float  *line;
 11     int     lx, ux, ly, uy;
 12     int     uxm1;
 13     int     i, j;
 14 
 15     if (image == NULL)
 16         return (NULL);
 17 
 18     lx = image->region->lx;
 19     ux = image->region->ux;
 20     ly = image->region->ly;
 21     uy = image->region->uy;
 22     uxm1 = ux - 1;
 23 
 24     grad_im = im_alloc(image->height, image->width, image->region, float_v);
 25     line = fvector_alloc(lx, ux);
 26 
 27     for (i = ly; i < uy; ++i)
 28     {
 29         im_get_rowf(line, image, i, lx, ux);
 30         IM_FLOAT(grad_im, i, lx) = line[lx + 1] - line[lx];
 31         for (j = lx + 1; j < uxm1; ++j)
 32             IM_FLOAT(grad_im, i, j) = (float)((line[j + 1] - line[j - 1]) * 0.5);
 33         IM_FLOAT(grad_im, i, uxm1) = line[uxm1] - line[uxm1 - 1];
 34     }
 35 
 36     fvector_free((void *) line, lx);
 37     return (grad_im);
 38 }
 39 
 40 Imrect *imf_grad_v(Imrect * image)
 41 {
 42     Imrect *grad_im;
 43     float  *line;
 44     int     lx, ux, ly, uy;
 45     int     uym1;
 46     int     i, j;
 47 
 48     if (image == NULL)
 49         return (NULL);
 50 
 51     lx = image->region->lx;
 52     ux = image->region->ux;
 53     ly = image->region->ly;
 54     uy = image->region->uy;
 55     uym1 = uy - 1;
 56 
 57     grad_im = im_alloc(image->height, image->width, image->region, float_v);
 58     line = fvector_alloc(ly, uy);
 59 
 60     for (i = lx; i < ux; ++i)
 61     {
 62         im_get_colf(line, image, i, ly, uy);
 63         IM_FLOAT(grad_im, ly, i) = line[ly + 1] - line[ly];
 64         for (j = ly + 1; j < uym1; ++j)
 65             IM_FLOAT(grad_im, j, i) = (float)((line[j + 1] - line[j - 1]) * 0.5);
 66         IM_FLOAT(grad_im, uym1, i) = line[uym1] - line[uym1 - 1];
 67     }
 68 
 69     fvector_free((void *) line, ly);
 70     return (grad_im);
 71 }
 72 

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