Changeset 11627 for ImageMagick/trunk
- Timestamp:
- 07/13/08 22:55:01 (7 weeks ago)
- Files:
-
- 1 modified
-
ImageMagick/trunk/magick/distort.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ImageMagick/trunk/magick/distort.c
r11617 r11627 270 270 switch(n) { 271 271 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 */ 292 292 } 293 293 return( "UNKNOWN" ); /* should never happen */ … … 565 565 coefficients[1], coefficients[3], coefficients[5]); 566 566 fprintf(stderr, "Affine Forward Map\n"); 567 fprintf(stderr, " -distort AffineProjection \\\n '");567 fprintf(stderr, " -distort AffineProjection \\\n '"); 568 568 for (i=0; i<5; i++) 569 569 fprintf(stderr, "%lg,", inverse[i]); … … 595 595 fprintf(stderr, " yy=%+lf*i %+lf*j %+lf; p{xx,yy}'\n", 596 596 coefficients[1], coefficients[3], coefficients[5]); 597 /* No AffineProjection output, as that is what was given! */ 597 598 } 598 599 return(coefficients); … … 857 858 vectors[1] = &(coefficients[nterms+1]); 858 859 /* 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) { 860 861 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]); 862 863 LeastSquaresAddTerms(matrix,vectors,terms,&(arguments[i]),nterms,2UL); 863 864 } … … 980 981 return((double *) NULL); 981 982 } 983 /* Save the given arguments as an affine distortion */ 984 *method = AffineDistortion; 982 985 a=DegreesToRadians(a); 983 986 cosine=cos(a); … … 1000 1003 } 1001 1004 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);1019 1005 fprintf(stderr, "Affine Reverse Map\n"); 1020 1006 fprintf(stderr, " -fx 'xx=%+lf*i %+lf*j %+lf;\n", … … 1023 1009 coefficients[1], coefficients[3], coefficients[5]); 1024 1010 fprintf(stderr, "Affine Forward Map\n"); 1025 fprintf(stderr, " -distort AffineProjection \\\n '");1011 fprintf(stderr, " -distort AffineProjection \\\n '"); 1026 1012 for (i=0; i<5; i++) 1027 1013 fprintf(stderr, "%lg,", inverse[i]); … … 1514 1500 1515 1501 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++) { 1517 1503 point.x += poly_term(k,x,y)*coefficients[k+1]; 1518 1504 dudx += poly_term_dx(k,x,y)*coefficients[k+1]; … … 1540 1526 ScaleResampleFilter( resample_filter[id], 1541 1527 coefficients[1]/(2*MagickPI)/point.y, 0, 0, coefficients[3] ); 1528 //coefficients[1]*2*MagickPI/point.y, 0, 0, coefficients[3] ); 1542 1529 else 1543 1530 ScaleResampleFilter( resample_filter[id],
