]> granicus.if.org Git - imagemagick/commitdiff
-sparse-color Inverse method
authoranthony <anthony@git.imagemagick.org>
Tue, 26 Apr 2011 08:28:41 +0000 (08:28 +0000)
committeranthony <anthony@git.imagemagick.org>
Tue, 26 Apr 2011 08:28:41 +0000 (08:28 +0000)
ChangeLog
magick/distort.c
magick/distort.h
magick/option.c

index be05d9d8383d401846d1feab7cac9147c0d31c38..84dbddd0cd37985e0329bd56d79767b933b8760e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
 
 2011-04-25  6.6.9-7 Anthony Thyssen <A.Thyssen@griffith...>
   * Separate simple image operations from 'region' wrappers.
-
+  * Added Inverse method for Sparse Color Interpolation
 
 2011-04-24  6.6.9-6 Cristy  <quetzlzacatenango@image...>
   * New version 6.6.9-6.
index 3243f03a9a2d07ab877f5cb2dacae957a5421289..4734ed8eb0793bd68d6fb11eb99d28492a088c5a 100644 (file)
@@ -410,6 +410,7 @@ static double *GenerateCoefficients(const Image *image,
       break;
     case ShepardsDistortion:
     case VoronoiColorInterpolate:
+    case InverseColorInterpolate:
       number_coeff=1;  /* not used, but provide some type of return */
       break;
     case ArcDistortion:
@@ -1288,6 +1289,7 @@ static double *GenerateCoefficients(const Image *image,
       return(coeff);
     }
     case ShepardsDistortion:
+    case InverseColorInterpolate:
     case VoronoiColorInterpolate:
     {
       /* Shepards Distortion  input arguments are the coefficents!
@@ -2788,6 +2790,7 @@ MagickExport Image *SparseColorImage(const Image *image,
             break;
           }
           case ShepardsColorInterpolate:
+          case InverseColorInterpolate:
           { /* Shepards Method, uses its own input arguments as coefficients.
             */
             size_t
@@ -2806,10 +2809,9 @@ MagickExport Image *SparseColorImage(const Image *image,
               double weight =
                   ((double)i-arguments[ k ])*((double)i-arguments[ k ])
                 + ((double)j-arguments[k+1])*((double)j-arguments[k+1]);
-              if ( weight != 0 )
-                weight = 1/weight;
-              else
-                weight = 1;
+              if ( method == InverseColorInterpolate )
+                weight = sqrt(weight);  /* inverse, not inverse squared */
+              weight = ( weight < 1 ) ? 1 : 1/weight;
               if ( channel & RedChannel )
                 pixel.red     += arguments[x++]*weight;
               if ( channel & GreenChannel )
index 1a2480bd540fa7b1115e316b5ae200017ab8d090..143887cb3f8e4e8b8c258bf6f4fe29f9915a6acb 100644 (file)
@@ -63,7 +63,8 @@ typedef enum
   /*
     Methods unique to SparseColor().
   */
-  VoronoiColorInterpolate = SentinelDistortion
+  VoronoiColorInterpolate = SentinelDistortion,
+  InverseColorInterpolate
 } SparseColorMethod;
 
 extern MagickExport Image
index 04d723723d6e0c31c8335c0efdd85ee6709ff69d..755022ec4d8b76e0d0de938e655fb56589fa8d0b 100644 (file)
@@ -1422,6 +1422,7 @@ static const OptionInfo
     { "Undefined", UndefinedDistortion, UndefinedOptionFlag, MagickTrue },
     { "Barycentric", BarycentricColorInterpolate, UndefinedOptionFlag, MagickFalse },
     { "Bilinear", BilinearColorInterpolate, UndefinedOptionFlag, MagickFalse },
+    { "Inverse", InverseColorInterpolate, UndefinedOptionFlag, MagickFalse },
     { "Shepards", ShepardsColorInterpolate, UndefinedOptionFlag, MagickFalse },
     { "Voronoi", VoronoiColorInterpolate, UndefinedOptionFlag, MagickFalse },
     { (char *) NULL, UndefinedResource, UndefinedOptionFlag, MagickFalse }