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

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

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

  1 /* im_quad.c
  2 
  3    Update: S.Crossley
  4    Date  : 9-5-96; version 2.0
  5 */
  6 
  7 #include <math.h>
  8 #include <tina/sys.h>
  9 #include <tina/sysfuncs.h>
 10 #include <tina/math.h>
 11 #include <tina/mathfuncs.h>
 12 #include <tina/vision.h>
 13 #include <tina/visionfuncs.h>
 14 
 15 /* sic 22-4-96
 16    old im_quad written by NAT renamed im_quad2
 17    new un_quad function successfully quads any sized image */
 18 
 19 Imrect *im_quad(Imrect *im)
 20 {
 21   Imrect *im2;
 22   Imregion roi;
 23   double pixval;
 24   int lx,ux,ly,uy;
 25   int i,j;
 26 
 27   if (im->vtype == complex_v) return (NULL);
 28   roi = *(Imregion *)im->region;
 29 
 30   lx = roi.lx;
 31   ux = roi.ux;
 32   ly = roi.ly;
 33   uy = roi.uy;
 34 
 35   roi.ux+=ux-lx;
 36   roi.uy+=uy-ly;
 37   
 38   im2 = im_alloc(2*im->height,2*im->width,&roi,im->vtype);
 39   
 40   for(i = ly; i < uy; i++)
 41     {
 42       for (j = lx; j < ux; j++)
 43         {
 44           IM_PIX_GET(im,i,j,pixval);
 45           IM_PIX_SET(im2,i,j,pixval);
 46           IM_PIX_SET(im2,i,roi.ux+roi.lx-j-1,pixval);
 47           IM_PIX_SET(im2,roi.uy+roi.ly-i-1,j,pixval);
 48           IM_PIX_SET(im2,roi.uy+roi.ly-i-1,roi.ux+roi.lx-j-1,pixval);
 49         }
 50     }
 51   return(im2);
 52 }
 53 
 54 Imrect *im_square(Imrect *im)
 55 {
 56   Imrect *im2;
 57   Imregion roi;
 58   double pixval;
 59   int lx,ux,ly,uy;
 60   int i,j,geti,getj;
 61 
 62   if (im->vtype == complex_v) return (NULL);
 63   roi = *(Imregion *)im->region;
 64 
 65   lx = roi.lx;
 66   ux = roi.ux;
 67   ly = roi.ly;
 68   uy = roi.uy;
 69 
 70   if (ux - lx > uy -ly)
 71   {
 72       roi.ly = ly - (ux - uy)/2;
 73       roi.uy = uy + (ux - uy)/2;
 74   }
 75   else
 76   {
 77       roi.lx = lx - (uy - ux)/2;
 78       roi.ux = ux + (uy - ux)/2;
 79   }
 80   im2 = im_alloc(im->height,im->width,&roi,im->vtype);
 81 
 82 
 83   for(i = roi.ly; i < roi.uy; i++)
 84    {
 85       if ((int)floor((float)i/(float)(uy-ly))%2!=0)
 86          geti = floor(i/(float)(uy-ly)+1)*(uy-ly)-i-1;
 87       else
 88          geti = i-floor(i/(float)(uy-ly))*(uy-ly);
 89 
 90       for (j = roi.lx; j < roi.ux; j++)
 91        {
 92           if ((int)floor((float)j/(float)(ux-lx))%2!=0)
 93              getj = floor(j/(float)(ux-lx)+1)*(ux-lx)-j-1;
 94           else
 95              getj = j-floor(j/(float)(ux-lx))*(ux-lx);
 96 
 97           IM_PIX_GET(im,geti,getj,pixval);
 98           IM_PIX_SET(im2,i,j,pixval);
 99        }
100    }
101   return(im2);
102 }
103 
104 
105 Imrect *im_quad2(Imrect *im)
106 {
107   Imrect *im2;
108   Imregion roi;
109   double pixval;
110   int lx,ux,ly,uy,nx,ny;
111   int i,j;
112 
113   if (im->vtype == complex_v) return (NULL);
114   roi = *(Imregion *)im->region;
115   lx = roi.lx;
116   ux = roi.ux;
117   ly = roi.ly;
118   uy = roi.uy;
119   for(nx = 1; nx <= ux-lx; nx *= 2);
120   for(ny = 1; ny <= uy-ly; ny *= 2);
121   nx/=2;
122   ny/=2;
123   
124   ux = roi.ux = lx + nx;
125   uy = roi.uy = ly + ny;
126 
127   roi.ux+=ux-lx;
128   roi.uy+=uy-ly;
129 
130   im2 = im_alloc(2*im->height,2*im->width,&roi,im->vtype);
131 
132   for(i = ly; i < uy; i++)
133     {
134       for (j = lx; j < ux;j++)
135         {
136           IM_PIX_GET(im,i,j,pixval);
137           IM_PIX_SET(im2,i,j,pixval);
138           IM_PIX_SET(im2,i,roi.ux+roi.lx-j-1,pixval);
139           IM_PIX_SET(im2,roi.uy+roi.ly-i-1,j,pixval);
140           IM_PIX_SET(im2,roi.uy+roi.ly-i-1,roi.ux+roi.lx-j-1,pixval);
141         }
142     }
143   return(im2);
144 }
145 
146 
147 

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