Changeset 11595 for ImageMagick/trunk

Show
Ignore:
Timestamp:
07/08/08 04:01:13 (7 weeks ago)
Author:
anthony
Message:

Minor fixes and repairs, in preparation for major work.

Location:
ImageMagick/trunk/magick
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • ImageMagick/trunk/magick/distort.c

    r11191 r11595  
    114114*/ 
    115115 
    116 #if 0 
    117 /* This function is no longer requires -- to be removed */ 
    118  
    119 static MagickBooleanType SolveAffineDistortion( 
    120   const unsigned long number_points,const PointInfo *points,double **matrix, 
    121   double *vector) 
    122 { 
    123   /* 
    124     Given the transformations of the coordinates for two triangles 
    125       u0,v0, x0,y0,  u1,v1, x1,y1,  u2,v2, x2,y2, ... 
    126  
    127     Solve for the 6 cofficients c0..c6 for a affine distortion: 
    128       u = c0*x + c2*y + c4 
    129       v = c1*x + c3*y + c5 
    130   */ 
    131   register int 
    132     i; 
    133   double 
    134     x,y,u,v; 
    135   if (number_points < 6) 
    136     return(MagickFalse); 
    137   for( i = 0; i < 6; ) { 
    138     u = points[i].x; 
    139     v = points[i].y; 
    140     x = points[i+1].x; 
    141     y = points[i+1].y; 
    142  
    143     vector[i]=u; 
    144     matrix[i][0]=x; 
    145     matrix[i][2]=y; 
    146     matrix[i][4]=1.0; 
    147     i++; 
    148  
    149     vector[i]=v; 
    150     matrix[i][1]=x; 
    151     matrix[i][3]=y; 
    152     matrix[i][5]=1.0; 
    153     i++; 
    154   } 
    155   return(GaussJordanElimination(matrix,&vector,6UL,1UL)); 
    156 } 
    157 #endif 
    158  
    159116static void InvertAffineCoefficients(const double *coefficients,double *inverse) 
    160117{ 
     
    170127} 
    171128 
    172 #if 0 
    173 /* This function is no longer requires -- to be removed */ 
    174  
    175 static MagickBooleanType SolveBilinearDistortion( 
    176   const unsigned long number_points,const PointInfo *points,double **matrix, 
    177   double *vector) 
    178 { 
    179   /* 
    180     Given the transformations of the coordinates of two quadrilaterals: 
    181       u0,v0, x0,y0,  u1,v1, x1,y1,  u2,v2, x2,y2, ... 
    182  
    183     Solve for the 8 coeffecients c0..c7 for a bilinear distortion: 
    184       u = c0*x + c1*y + c2*x*y + c3 
    185       v = c4*x + c5*y + c6*x*y + c7 
    186   */ 
    187   register int 
    188     i; 
    189   double 
    190     x,y,u,v; 
    191   if (number_points < 8) 
    192     return(MagickFalse); 
    193   for( i = 0; i < 8; ) { 
    194     u = points[i].x; 
    195     v = points[i].y; 
    196     x = points[i+1].x; 
    197     y = points[i+1].y; 
    198  
    199     vector[i]=u; 
    200     matrix[i][0]=x; 
    201     matrix[i][1]=y; 
    202     matrix[i][2]=x*y; 
    203     matrix[i][3]=1.0; 
    204     i++; 
    205  
    206     vector[i]=v; 
    207     matrix[i][4]=x; 
    208     matrix[i][5]=y; 
    209     matrix[i][6]=x*y; 
    210     matrix[i][7]=1.0; 
    211     i++; 
    212   } 
    213   return(GaussJordanElimination(matrix,&vector,8UL,1UL)); 
    214 } 
    215  
    216 static MagickBooleanType SolvePerspectiveDistortion( 
    217   const unsigned long number_points,const PointInfo *points,double **matrix, 
    218   double *vector) 
    219 { 
    220   /* 
    221     Given the coordinates of two quadrilaterals: 
    222       u0,v0, x0,y0,  u1,v1, x1,y1,  u2,v2, x2,y2, ... 
    223  
    224     Solve for the 8 coefficients c0..c7 for a perspective distortion: 
    225        u = ( c0*x + c1*y + c2 ) / ( c6*x + c7*y + 1 ) 
    226        v = ( c3*x + c4*y + c5 ) / ( c6*x + c7*y + 1 ) 
    227    */ 
    228   register int 
    229     i; 
    230   double 
    231     x,y,u,v; 
    232   if (number_points < 8) 
    233     return(MagickFalse); 
    234   for( i = 0; i < 8; ) { 
    235     u = points[i].x; 
    236     v = points[i].y; 
    237     x = points[i+1].x; 
    238     y = points[i+1].y; 
    239  
    240     vector[i]=u; 
    241     matrix[i][0]=x; 
    242     matrix[i][1]=y; 
    243     matrix[i][2]=1.0; 
    244     matrix[i][6]=-x*u; 
    245     matrix[i][7]=-y*u; 
    246     i++; 
    247  
    248     vector[i]=v; 
    249     matrix[i][3]=x; 
    250     matrix[i][4]=y; 
    251     matrix[i][5]=1.0; 
    252     matrix[i][6]=-x*v; 
    253     matrix[i][7]=-y*v; 
    254     i++; 
    255   } 
    256   return(GaussJordanElimination(matrix,&vector,8UL,1UL)); 
    257 } 
    258 #endif 
    259129 
    260130static void InvertPerspectiveCoefficients(const double *coefficients, 
     
    283153  return((double) ((long) (x-0.5))); 
    284154} 
     155 
    285156 
    286157MagickExport Image *DistortImage(Image *image,const DistortImageMethod method, 
     
    394265        /* Affine has a bit of a weird ordering of coefficents. 
    395266           This ordering is for backward compatibility with the older 
    396            affine functions of IM. 
     267           affine functions of IM. (See AffineProjection next) 
    397268        */ 
    398269        coefficients[0] = vectors[0][0]; /* u = ... */ 
     
    569440        Calculate 9'th coefficient! The ground-sky determination. 
    570441        What is sign of the 'ground' in r() denominator affine function? 
    571         Just use any valid image cocodinate in destination for determination. 
    572         Picking destination coordinate from first coordinet pair.   
     442        Just use any valid image coordinate in destination for determination. 
     443        Picking destination coordinate from first coordinate pair. 
    573444      */ 
    574445      coefficients[8] = coefficients[6]*arguments[2] 
     
    683554      } 
    684555      /* FUTURE: trap if sx or sy == 0 -- image is scaled out of existance! */ 
     556      if ( fabs(sx) < MagickEpsilon || fabs(sy) < MagickEpsilon ) { 
     557        (void) ThrowMagickException(exception,GetMagickModule(),OptionError, 
     558                     "InvalidArgument","%s : '%s'", 
     559                     "distort ScaleTranslateRotate", 
     560                     "Zero Scale"); 
     561        return((Image *) NULL); 
     562      } 
    685563      a=DegreesToRadians(a); 
    686564      cosine=cos(a); 
     
    974852          point.x=coefficients[0]*x+coefficients[2]*y+coefficients[4]; 
    975853          point.y=coefficients[1]*x+coefficients[3]*y+coefficients[5]; 
    976           /* Affine partical derivitives are constant -- set above */ 
     854          /* Affine partial derivitives are constant -- set above */ 
    977855          break; 
    978856        } 
     
    983861          point.y=coefficients[4]*x+coefficients[5]*y+coefficients[6]*x*y+ 
    984862            coefficients[7]; 
    985           /* Bilinear partical derivitives of scaling vectors */ 
     863          /* Bilinear partial derivitives of scaling vectors */ 
    986864          ScaleResampleFilter( resample_filter, 
    987865              coefficients[0] + coefficients[2]*y, 
  • ImageMagick/trunk/magick/matrix.c

    r10678 r11595  
    6262%  for the GaussJordanElimination() method below, solving some system of 
    6363%  simultanious equations. 
    64  
     64% 
    6565%  The format of the AcquireMagickMatrix method is: 
    6666% 
     
    328328% 
    329329%     2 dimentional Affine Equations (which are separable) 
    330 %       c0*x + c2*y + c4*1 => u 
    331 %      c1*x + c3*y + c5*1 => v 
     330%         c0*x + c2*y + c4*1 => u 
     331%         c1*x + c3*y + c5*1 => v 
    332332% 
    333333%     double **matrix = AcquireMagickMatrix(3UL,3UL);