]> granicus.if.org Git - imagemagick/commitdiff
https://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=32506
authorCristy <urban-warrior@imagemagick.org>
Tue, 15 Aug 2017 22:44:44 +0000 (18:44 -0400)
committerCristy <urban-warrior@imagemagick.org>
Tue, 15 Aug 2017 22:44:44 +0000 (18:44 -0400)
ChangeLog
MagickCore/option.c
MagickCore/resample.h
MagickCore/resize.c

index 7fa05948f1855576a87dcd6234b2cdb50bb63d01..53980e85236aea5636ec528841f4c13cefd35a46 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
 2017-08-14  7.0.6-7 Cristy  <quetzlzacatenango@image...>
   * Fixed numerous memory leaks (reference
     https://github.com/ImageMagick/ImageMagick/issues).
-  * Support spline-lobes resize filter.  Define the lobes with the
+  * Support CubicSpline resize filter.  Define the lobes with the
     -define filter:lobes={2,3,4} (reference
     https://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=32506).
   * Prevent assertion failure when creating PDF thumbnail (reference
index e3bd97ec56952d94394ca25f789d9f5b99c4a6d6..2fb55175de264bc4515d5c18ee58e29de51268bf 100644 (file)
@@ -1164,7 +1164,7 @@ static const OptionInfo
     { "Sinc", SincFilter, UndefinedOptionFlag, MagickFalse },
     { "SincFast", SincFastFilter, UndefinedOptionFlag, MagickFalse },
     { "Spline", SplineFilter, UndefinedOptionFlag, MagickFalse },
-    { "SplineLobes", SplineLobesFilter, UndefinedOptionFlag, MagickFalse },
+    { "CubicSpline", CubicSplineFilter, UndefinedOptionFlag, MagickFalse },
     { "Triangle", TriangleFilter, UndefinedOptionFlag, MagickFalse },
     { "Welch", WelchFilter, UndefinedOptionFlag, MagickFalse },
     { "Welsh", WelchFilter, UndefinedOptionFlag, MagickTrue }, /*misspell*/
index 6fdbc532e90835f9d48567f382c203eadd9c5a71..2086e3c5cf32095f041a0efbdeabe43d1c4913ea 100644 (file)
@@ -62,7 +62,7 @@ typedef enum
   CosineFilter,
   SplineFilter,
   LanczosRadiusFilter,
-  SplineLobesFilter,
+  CubicSplineFilter,
   SentinelFilter  /* a count of all the filters, not a real filter */
 } FilterType;
 
index 7bf59e17f967ee2954daf616bb086951f388dc9a..608e086c314e1719889d7c1e01797fa189dbf9e6 100644 (file)
@@ -244,6 +244,46 @@ static double CubicBC(const double x,const ResizeFilter *resize_filter)
   return(0.0);
 }
 
+static double CubicSpline(const double x,const ResizeFilter *resize_filter)
+{
+  if (resize_filter->support <= 2.0)
+    {
+      /*
+        2-lobe Spline filter.
+      */
+      if (x < 1.0)
+        return(((x-9.0/5.0)*x-1.0/5.0)*x+1.0);
+      if (x < 2.0)
+        return(((-1.0/3.0*(x-1.0)+4.0/5.0)*(x-1.0)-7.0/15.0)*(x-1.0));
+      return(0.0);
+    }
+  if (resize_filter->support <= 3.0)
+    {
+      /*
+        3-lobe Spline filter.
+      */
+      if (x < 1.0)
+        return(((13.0/11.0*x-453.0/209.0)*x-3.0/209.0)*x+1.0);
+      if (x < 2.0)
+        return(((-6.0/11.0*(x-1.0)+270.0/209.0)*(x-1.0)-156.0/209.0)*(x-1.0));
+      if (x < 3.0)
+        return(((1.0/11.0*(x-2.0)-45.0/209.0)*(x-2.0)+26.0/209.0)*(x-2.0));
+      return(0.0);
+    }
+  /*
+    4-lobe Spline filter.
+  */
+  if (x < 1.0)
+    return(((49.0/41.0*x-6387.0/2911.0)*x-3.0/2911.0)*x+1.0);
+  if (x < 2.0)
+    return(((-24.0/41.0*(x-1.0)+4032.0/2911.0)*(x-1.0)-2328.0/2911.0)*(x-1.0));
+  if (x < 3.0)
+    return(((6.0/41.0*(x-2.0)-1008.0/2911.0)*(x-2.0)+582.0/2911.0)*(x-2.0));
+  if (x < 4.0)
+    return(((-1.0/41.0*(x-3.0)+168.0/2911.0)*(x-3.0)-97.0/2911.0)*(x-3.0));
+  return(0.0);
+}
+
 static double Gaussian(const double x,const ResizeFilter *resize_filter)
 {
   /*
@@ -500,46 +540,6 @@ static double SincFast(const double x,
   }
 }
 
-static double SplineLobes(const double x,const ResizeFilter *resize_filter)
-{
-  if (resize_filter->support <= 2.0)
-    {
-      /*
-        2-lobe Spline filter.
-      */
-      if (x < 1.0)
-        return(((x-9.0/5.0)*x-1.0/5.0)*x+1.0);
-      if (x < 2.0)
-        return(((-1.0/3.0*(x-1.0)+4.0/5.0)*(x-1.0)-7.0/15.0)*(x-1.0));
-      return(0.0);
-    }
-  if (resize_filter->support <= 3.0)
-    {
-      /*
-        3-lobe Spline filter.
-      */
-      if (x < 1.0)
-        return(((13.0/11.0*x-453.0/209.0)*x-3.0/209.0)*x+1.0);
-      if (x < 2.0)
-        return(((-6.0/11.0*(x-1.0)+270.0/209.0)*(x-1.0)-156.0/209.0)*(x-1.0));
-      if (x < 3.0)
-        return(((1.0/11.0*(x-2.0)-45.0/209.0)*(x-2.0)+26.0/209.0)*(x-2.0));
-      return(0.0);
-    }
-  /*
-    4-lobe Spline filter.
-  */
-  if (x < 1.0)
-    return(((49.0/41.0*x-6387.0/2911.0)*x-3.0/2911.0)*x+1.0);
-  if (x < 2.0)
-    return(((-24.0/41.0*(x-1.0)+4032.0/2911.0)*(x-1.0)-2328.0/2911.0)*(x-1.0));
-  if (x < 3.0)
-    return(((6.0/41.0*(x-2.0)-1008.0/2911.0)*(x-2.0)+582.0/2911.0)*(x-2.0));
-  if (x < 4.0)
-    return(((-1.0/41.0*(x-3.0)+168.0/2911.0)*(x-3.0)-97.0/2911.0)*(x-3.0));
-  return(0.0);
-}
-
 static double Triangle(const double x,
   const ResizeFilter *magick_unused(resize_filter))
 {
@@ -824,7 +824,7 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image,
     { LanczosFilter,       CosineFilter   },  /* Cosine window (3 lobes)      */
     { SplineFilter,        BoxFilter      },  /* Spline Cubic Filter          */
     { LanczosRadiusFilter, LanczosFilter  },  /* Lanczos with integer radius  */
-    { SplineLobesFilter,   BoxFilter      },  /* SplineLobes (n lobes)  */
+    { CubicSplineFilter,   BoxFilter      },  /* CubicSpline (2/3/4 lobes)    */
   };
   /*
     Table mapping the filter/window from the above table to an actual function.
@@ -888,7 +888,7 @@ MagickPrivate ResizeFilter *AcquireResizeFilter(const Image *image,
     { Cosine,    1.0, 1.0, 0.0, 0.0, CosineWeightingFunction },   /* Low level cosine window     */
     { CubicBC,   2.0, 2.0, 1.0, 0.0, CubicBCWeightingFunction },  /* Cubic B-Spline (B=1,C=0)    */
     { SincFast,  3.0, 1.0, 0.0, 0.0, SincFastWeightingFunction }, /* Lanczos, Interger Radius    */
-    { SplineLobes,  2.0, 0.5, 0.0, 0.0, BoxWeightingFunction },  /* Spline Lobes 2-lobed */
+    { CubicSpline,2.0, 0.5, 0.0, 0.0, BoxWeightingFunction },  /* Spline Lobes 2-lobed */
   };
   /*
     The known zero crossings of the Jinc() or more accurately the Jinc(x*PI)