Changeset 11627 for ImageMagick/trunk

Show
Ignore:
Timestamp:
07/13/08 22:55:01 (7 weeks ago)
Author:
anthony
Message:
 
Files:
1 modified

Legend:

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

    r11617 r11627  
    270270  switch(n) { 
    271271    case  0:  return(""); /* constant */ 
    272     case  1:  return("*xx"); 
    273     case  2:  return("*yy"); /* affine      order = 1   terms = 3 */ 
    274     case  3:  return("*xx*yy"); /* bilinear    order = 1.5 terms = 4 */ 
    275     case  4:  return("*xx*xx"); 
    276     case  5:  return("*yy*yy"); /* quadratic   order = 2   terms = 6 */ 
    277     case  6:  return("*xx*xx*xx"); 
    278     case  7:  return("*xx*xx*yy"); 
    279     case  8:  return("*xx*yy*yy"); 
    280     case  9:  return("*yy*yy*yy"); /* cubic       order = 3   terms = 10 */ 
    281     case 10:  return("*xx*xx*xx*xx"); 
    282     case 11:  return("*xx*xx*xx*yy"); 
    283     case 12:  return("*xx*xx*yy*yy"); 
    284     case 13:  return("*xx*yy*yy*yy"); 
    285     case 14:  return("*yy*yy*yy*yy"); /* quartic     order = 4   terms = 15 */ 
    286     case 15:  return("*xx*xx*xx*xx*xx"); 
    287     case 16:  return("*xx*xx*xx*xx*yy"); 
    288     case 17:  return("*xx*xx*xx*yy*yy"); 
    289     case 18:  return("*xx*xx*yy*yy*yy"); 
    290     case 19:  return("*xx*yy*yy*yy*yy"); 
    291     case 20:  return("*yy*yy*yy*yy*yy"); /* quintic     order = 5   terms = 21 */ 
     272    case  1:  return("*i"); 
     273    case  2:  return("*j"); /* affine      order = 1   terms = 3 */ 
     274    case  3:  return("*i*j"); /* bilinear    order = 1.5 terms = 4 */ 
     275    case  4:  return("*i*i"); 
     276    case  5:  return("*j*j"); /* quadratic   order = 2   terms = 6 */ 
     277    case  6:  return("*i*i*i"); 
     278    case  7:  return("*i*i*j"); 
     279    case  8:  return("*i*j*j"); 
     280    case  9:  return("*j*j*j"); /* cubic       order = 3   terms = 10 */ 
     281    case 10:  return("*i*i*i*i"); 
     282    case 11:  return("*i*i*i*j"); 
     283    case 12:  return("*i*i*j*j"); 
     284    case 13:  return("*i*j*j*j"); 
     285    case 14:  return("*j*j*j*j"); /* quartic     order = 4   terms = 15 */ 
     286    case 15:  return("*i*i*i*i*i"); 
     287    case 16:  return("*i*i*i*i*j"); 
     288    case 17:  return("*i*i*i*j*j"); 
     289    case 18:  return("*i*i*j*j*j"); 
     290    case 19:  return("*i*j*j*j*j"); 
     291    case 20:  return("*j*j*j*j*j"); /* quintic     order = 5   terms = 21 */ 
    292292  } 
    293293  return( "UNKNOWN" ); /* should never happen */ 
     
    565565            coefficients[1], coefficients[3], coefficients[5]); 
    566566        fprintf(stderr, "Affine Forward Map\n"); 
    567         fprintf(stderr, "  -distort AffineProjection \\\n  '"); 
     567        fprintf(stderr, "  -distort AffineProjection \\\n      '"); 
    568568        for (i=0; i<5; i++) 
    569569          fprintf(stderr, "%lg,", inverse[i]); 
     
    595595        fprintf(stderr, "       yy=%+lf*i %+lf*j %+lf; p{xx,yy}'\n", 
    596596            coefficients[1], coefficients[3], coefficients[5]); 
     597        /* No AffineProjection output, as that is what was given! */ 
    597598      } 
    598599      return(coefficients); 
     
    857858      vectors[1] = &(coefficients[nterms+1]); 
    858859      /* Add control points for least squares solving */ 
    859       for (i=2; i < (long) number_arguments; i+=4) { 
     860      for (i=0; i < (long)number_arguments; i+=4) { 
    860861        for (j=0; j < nterms; j++) 
    861           terms[j] = poly_term(j,arguments[i],arguments[i+1]); 
     862          terms[j] = poly_term(j,arguments[i=2],arguments[i+3]); 
    862863        LeastSquaresAddTerms(matrix,vectors,terms,&(arguments[i]),nterms,2UL); 
    863864      } 
     
    980981        return((double *) NULL); 
    981982      } 
     983      /* Save the given arguments as an affine distortion */ 
     984      *method = AffineDistortion; 
    982985      a=DegreesToRadians(a); 
    983986      cosine=cos(a); 
     
    10001003        } 
    10011004        InvertAffineCoefficients(coefficients, inverse); 
    1002         fprintf(stderr, "Affine ReverseMap\n"); 
    1003         for (i=0; i<6; i++) 
    1004           fprintf(stderr, "  %lf\n", coefficients[i]); 
    1005         fprintf(stderr, "AffineProjection\n"); 
    1006         for (i=0; i<6; i++) 
    1007           fprintf(stderr, "  %lf\n", inverse[i]); 
    1008       } 
    1009       if ( GetImageArtifact(image,"distort:verbose") != (const char *) NULL ) { 
    1010         double *inverse = AcquireQuantumMemory(8,sizeof(coefficients[i])); 
    1011         if (inverse == (double *) NULL) { 
    1012           coefficients = RelinquishMagickMemory(coefficients); 
    1013           (void) ThrowMagickException(exception,GetMagickModule(), 
    1014                   ResourceLimitError,"MemoryAllocationFailed", 
    1015                   "%s", "DistortCoefficients"); 
    1016           return((double *) NULL); 
    1017         } 
    1018         InvertAffineCoefficients(coefficients, inverse); 
    10191005        fprintf(stderr, "Affine Reverse Map\n"); 
    10201006        fprintf(stderr, "  -fx 'xx=%+lf*i %+lf*j %+lf;\n", 
     
    10231009            coefficients[1], coefficients[3], coefficients[5]); 
    10241010        fprintf(stderr, "Affine Forward Map\n"); 
    1025         fprintf(stderr, "  -distort AffineProjection \\\n  '"); 
     1011        fprintf(stderr, "  -distort AffineProjection \\\n      '"); 
    10261012        for (i=0; i<5; i++) 
    10271013          fprintf(stderr, "%lg,", inverse[i]); 
     
    15141500 
    15151501          point.x=point.y=dudx=dudy=dvdx=dvdy=0.0; 
    1516           for(k=0; k < coefficients[0]; k++) { 
     1502          for(k=0; k < (long)coefficients[0]; k++) { 
    15171503            point.x += poly_term(k,x,y)*coefficients[k+1]; 
    15181504            dudx += poly_term_dx(k,x,y)*coefficients[k+1]; 
     
    15401526            ScaleResampleFilter( resample_filter[id], 
    15411527                coefficients[1]/(2*MagickPI)/point.y, 0, 0, coefficients[3] ); 
     1528              //coefficients[1]*2*MagickPI/point.y, 0, 0, coefficients[3] ); 
    15421529          else 
    15431530            ScaleResampleFilter( resample_filter[id],