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

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

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

  1 #include <stdio.h>
  2 #include <sys/param.h>
  3 #include <string.h>
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 #include <tina/mathfuncs.h>
  8 #include <tina/vision.h>
  9 #include <tina/visionfuncs.h>
 10 /*
 11 #include <tina/file.h>
 12 #include <tina/filefuncs.h>
 13 #include <tina/file_gen.h>
 14 #include <tina/draw.h>
 15 #include <tina/drawfuncs.h>
 16 #include <tina/tv.h>
 17 #include <tina/tvfuncs.h>
 18 #include <tina/toolsfuncs.h>
 19 #include <tina/tw_Xfuncs.h>
 20 #include <pgh/pgh_defs.h>
 21 #include <pgh/pgh_types.h>
 22 #include <pgh/pgh_funcs.h>
 23 
 24 #include <pgh/extra.h>
 25 */
 26 
 27 /* Rotates image around im_center. If im_center is passed as NULL
 28    the center of the passed image is used 
 29 
 30    Note: angle is in degrees 
 31 */
 32 
 33 Imrect *im_rotate(Imrect *im, double angle, Vec2 *im_center)
 34 {
 35     
 36     Mat2 M;
 37     Imrect *dest_im;
 38     Imregion *region;
 39     int lx, ly, ux, uy;
 40     int i, j;
 41     Vec2 OC;     /* O = origin, C = image center, P = pixel center */
 42     Vec2 OP;
 43     Vec2 CP;
 44     Vec2 CP_source;
 45     Vec2 OP_source;
 46     double v;
 47 
 48     if (im==NULL) return NULL;
 49 
 50     M = rot2(PI*(angle/180.0));
 51    
 52     dest_im = im_copy(im);
 53     region = dest_im->region;
 54 
 55     lx = region->lx;
 56     ly = region->ly;
 57     ux = region->ux;
 58     uy = region->uy;
 59 
 60     if (im_center==NULL)
 61     {
 62         vec2_x(OC) = (float)(ux-lx)/(float)2.0;
 63         vec2_y(OC) = (float)(uy-ly)/(float)2.0;
 64     }
 65     else
 66     {
 67         vec2_x(OC) = vec2_x(*im_center);
 68         vec2_y(OC) = vec2_y(*im_center);
 69     }
 70 
 71 
 72     for(j=ly;j<uy;j++)
 73     {
 74         vec2_y(OP) = (float)(j+0.5);
 75 
 76         for(i=lx;i<ux;i++)
 77         {
 78             vec2_x(OP) = (float)(i+0.5);
 79 
 80             CP = vec2_sum(OP, vec2_minus(OC));
 81           
 82             CP_source = mat2_vprod(M, CP);
 83             OP_source = vec2_sum(OC, CP_source);
 84 
 85             v = im_sub_pixqf(im, vec2_y(OP_source), vec2_x(OP_source));
 86             IM_PIX_SET(dest_im, j, i, v);
 87         }
 88     }
 89 
 90     return dest_im;
 91 }
 92 
 93 

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