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

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

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

  1 /* convolve.c
  2 
  3    Function to convolve two images. 
  4 
  5    Author: S.Crossley
  6    Date  : 29-7-96
  7 */
  8 
  9 #include <math.h>
 10 #include <tina/sys.h>
 11 #include <tina/sysfuncs.h>
 12 #include <tina/math.h>
 13 #include <tina/mathfuncs.h>
 14 #include <tina/vision.h>
 15 
 16 /* im_convolve implements a valid 2D convolution of an image and a
 17    kernel image, new_im is used to store the result, im is
 18    the image to be convoled, both new_im and im should be based
 19    on the same roi */
 20 
 21 void im_convolve(Imrect *new_im, Imrect *im, Imrect *kern)
 22 {
 23   Imregion *roi;                      /* temporary roi */
 24   int row, col, krow, kcol;           /* loop variables */
 25   int width, height, lower_x, lower_y, upper_x, upper_y, off_x, off_y;
 26 
 27   width = (int)abs(kern->region->ux - kern->region->lx);
 28   height = (int)abs(kern->region->uy - kern->region->ly);
 29 
 30   if ((width % 2)==0)
 31     {
 32       lower_x = -(int)(abs(width/2));
 33       upper_x = (int)(abs(width/2));
 34     }
 35   else 
 36     {
 37       lower_x = -(int)(abs(width/2));
 38       upper_x = (int)(abs(width/2))+1;
 39     }
 40   if ((height % 2)==0)
 41     {
 42       lower_y = -(int)(abs(height/2));
 43       upper_y = (int)(abs(height/2));
 44     }
 45   else 
 46     {
 47       lower_y = -(int)(abs(height/2));
 48       upper_y = (int)(abs(height/2))+1;
 49     }
 50 
 51   roi = roi_alloc(lower_x, lower_y, upper_x, upper_y);
 52   
 53   off_x = kern->region->lx - lower_x;
 54   off_y = kern->region->ly - lower_y;
 55   
 56   FOR_IM(new_im->region, row, col)
 57     {
 58       IM_FLOAT(new_im, row, col) = 0.0;
 59 
 60       FOR_IM(roi, krow, kcol)
 61         IM_FLOAT(new_im, row, col) +=
 62         (IM_FLOAT(im, row+krow, col+kcol) * IM_FLOAT(kern, off_y+krow, off_x+kcol));
 63     }
 64 }
 65 
 66 

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