]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 21 Dec 2014 20:01:43 +0000 (20:01 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 21 Dec 2014 20:01:43 +0000 (20:01 +0000)
MagickCore/color.c
MagickCore/composite-private.h
MagickCore/composite.c
MagickCore/feature.c
MagickCore/identify.c
MagickCore/pixel.c
MagickCore/quantize.c
MagickCore/version.h
MagickCore/vision.c
coders/json.c

index 9e81e6e2744611ca5258578723df1eb4d48961d6..dba7d75aaff24e2f661ac1bf5b3979b7cd924bc1 100644 (file)
@@ -1546,18 +1546,18 @@ MagickExport void GetColorTuple(const PixelInfo *pixel,
       /*
         SVG requires color depths > 8 expressed as percentages.
       */
-      status=IsMagickTrue(fabs(color.red-SVGCompliant(color.red))
-           < MagickEpsilon);
-      status&=IsMagickTrue(fabs(color.green-SVGCompliant(color.green))
-           < MagickEpsilon);
-      status&=IsMagickTrue(fabs(color.blue-SVGCompliant(color.blue))
-           < MagickEpsilon);
+      status=IsMagickTrue(fabs((double) (color.red-
+        SVGCompliant(color.red))) < MagickEpsilon);
+      status&=IsMagickTrue(fabs((double) (color.green-
+        SVGCompliant(color.green))) < MagickEpsilon);
+      status&=IsMagickTrue(fabs((double) (color.blue-
+        SVGCompliant(color.blue))) < MagickEpsilon);
       if (color.colorspace-CMYKColorspace)
-        status&=IsMagickTrue(fabs(color.black-SVGCompliant(color.black))
-             < MagickEpsilon);
+        status&=IsMagickTrue(fabs((double) (color.black-
+          SVGCompliant(color.black))) < MagickEpsilon);
       if (color.alpha_trait != UndefinedPixelTrait)
-        status&=IsMagickTrue(fabs(color.alpha-SVGCompliant(color.alpha))
-             < MagickEpsilon);
+        status&=IsMagickTrue(fabs((double) (color.alpha-
+          SVGCompliant(color.alpha))) < MagickEpsilon);
       if (IfMagickTrue(status))
         color.depth=8;
     }
@@ -2587,10 +2587,10 @@ MagickExport MagickBooleanType QueryColorname(
   while (p != (const ColorInfo *) NULL)
   {
     if (((p->compliance & compliance) != 0) &&
-        ((fabs(p->color.red-color->red) < MagickEpsilon)) &&
-         (fabs(p->color.green-color->green) < MagickEpsilon) &&
-         (fabs(p->color.blue-color->blue) < MagickEpsilon) &&
-         (fabs(p->color.alpha-alpha) < MagickEpsilon))
+        ((fabs((double) (p->color.red-color->red)) < MagickEpsilon)) &&
+         (fabs((double) (p->color.green-color->green)) < MagickEpsilon) &&
+         (fabs((double) (p->color.blue-color->blue)) < MagickEpsilon) &&
+         (fabs((double) (p->color.alpha-alpha)) < MagickEpsilon))
       {
         (void) CopyMagickString(name,p->name,MaxTextExtent);
         break;
index c8ec865d97da3b8ab9f4f8a8734874ea15a1a7bf..f3f2feb80f590dc42fae3863091641f9b78b4470 100644 (file)
@@ -74,7 +74,7 @@ static inline void CompositePixelOver(const Image *image,const PixelInfo *p,
     traits=GetPixelChannelTraits(image,channel);
     if (traits == UndefinedPixelTrait)
       continue;
-    if (fabs(alpha-TransparentAlpha) < MagickEpsilon)
+    if (fabs((double) (alpha-TransparentAlpha)) < MagickEpsilon)
       {
         composite[i]=q[i];
         continue;
@@ -130,7 +130,7 @@ static inline void CompositePixelInfoOver(const PixelInfo *p,
   /*
     Compose pixel p over pixel q with the given opacities.
   */
-  if (fabs(alpha-TransparentAlpha) < MagickEpsilon)
+  if (fabs((double) (alpha-TransparentAlpha)) < MagickEpsilon)
     {
       *composite=(*p);
       return;
index 14d297df9f64ec1b3f090b091394d507812bada4..d9024bb6caa76b8aad9df637ee487de3cc96850c 100644 (file)
@@ -900,7 +900,7 @@ if (0)
               p+=GetPixelChannels(composite_image);
               continue;
             }
-          if (fabs(angle_range) > MagickEpsilon)
+          if (fabs((double) angle_range) > MagickEpsilon)
             {
               MagickRealType
                 angle;
@@ -1611,12 +1611,12 @@ if (0)
               case LuminizeCompositeOp:
               case SaturateCompositeOp:
               {
-                if (fabs(QuantumRange*Sa-TransparentAlpha) < MagickEpsilon)
+                if (fabs((double) (QuantumRange*Sa-TransparentAlpha)) < MagickEpsilon)
                   {
                     pixel=QuantumRange*Da;
                     break;
                   }
-                if (fabs(QuantumRange*Da-TransparentAlpha) < MagickEpsilon)
+                if (fabs((double) (QuantumRange*Da-TransparentAlpha)) < MagickEpsilon)
                   {
                     pixel=QuantumRange*Sa;
                     break;
@@ -1660,7 +1660,7 @@ if (0)
               }
               case ModulateCompositeOp:
               {
-                if (fabs(QuantumRange*Sa-TransparentAlpha) < MagickEpsilon)
+                if (fabs((double) (QuantumRange*Sa-TransparentAlpha)) < MagickEpsilon)
                   {
                     pixel=QuantumRange*Da;
                     break;
@@ -1728,7 +1728,7 @@ if (0)
           }
           case BumpmapCompositeOp:
           {
-            if (fabs(QuantumRange*Sa-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Sa-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Dc;
                 break;
@@ -1779,12 +1779,12 @@ if (0)
           }
           case ColorizeCompositeOp:
           {
-            if (fabs(QuantumRange*Sa-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Sa-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Dc;
                 break;
               }
-            if (fabs(QuantumRange*Da-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Da-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Sc;
                 break;
@@ -1870,12 +1870,13 @@ if (0)
           }
           case DivideDstCompositeOp:
           {
-            if ((fabs(Sca) < MagickEpsilon) && (fabs(Dca) < MagickEpsilon))
+            if ((fabs((double) Sca) < MagickEpsilon) &&
+                (fabs((double) Dca) < MagickEpsilon))
               {
                 pixel=QuantumRange*(Sca*(1.0-Da)+Dca*(1.0-Sa));
                 break;
               }
-            if (fabs(Dca) < MagickEpsilon)
+            if (fabs((double) Dca) < MagickEpsilon)
               {
                 pixel=QuantumRange*(Sa*Da+Sca*(1.0-Da)+Dca*(1.0-Sa));
                 break;
@@ -1885,12 +1886,13 @@ if (0)
           }
           case DivideSrcCompositeOp:
           {
-            if ((fabs(Dca) < MagickEpsilon) && (fabs(Sca) < MagickEpsilon))
+            if ((fabs((double) Dca) < MagickEpsilon) &&
+                (fabs((double) Sca) < MagickEpsilon))
               {
                 pixel=QuantumRange*(Dca*(1.0-Sa)+Sca*(1.0-Da));
                 break;
               }
-            if (fabs(Sca) < MagickEpsilon)
+            if (fabs((double) Sca) < MagickEpsilon)
               {
                 pixel=QuantumRange*(Da*Sa+Dca*(1.0-Sa)+Sca*(1.0-Da));
                 break;
@@ -1955,12 +1957,12 @@ if (0)
           }
           case HueCompositeOp:
           {
-            if (fabs(QuantumRange*Sa-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Sa-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Dc;
                 break;
               }
-            if (fabs(QuantumRange*Da-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Da-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Sc;
                 break;
@@ -2035,12 +2037,12 @@ if (0)
           }
           case LuminizeCompositeOp:
           {
-            if (fabs(QuantumRange*Sa-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Sa-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Dc;
                 break;
               }
-            if (fabs(QuantumRange*Da-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Da-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Sc;
                 break;
@@ -2105,7 +2107,7 @@ if (0)
             ssize_t
               offset;
 
-            if (fabs(QuantumRange*Sa-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Sa-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Dc;
                 break;
@@ -2184,7 +2186,7 @@ if (0)
 
               http://www.pegtop.net/delphi/articles/blendmodes/softlight.htm.
             */
-            if (fabs(Da) < MagickEpsilon)
+            if (fabs((double) Da) < MagickEpsilon)
               {
                 pixel=QuantumRange*(Sca);
                 break;
@@ -2221,12 +2223,12 @@ if (0)
           }
           case SaturateCompositeOp:
           {
-            if (fabs(QuantumRange*Sa-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Sa-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Dc;
                 break;
               }
-            if (fabs(QuantumRange*Da-TransparentAlpha) < MagickEpsilon)
+            if (fabs((double) (QuantumRange*Da-TransparentAlpha)) < MagickEpsilon)
               {
                 pixel=Sc;
                 break;
@@ -2296,7 +2298,8 @@ if (0)
 
                 f(Sc,Dc) = (2*Sc < 1) ? 1-(1-Dc)/(2*Sc) : Dc/(2*(1-Sc))
             */
-            if ((fabs(Sa) < MagickEpsilon) || (fabs(Sca-Sa) < MagickEpsilon))
+            if ((fabs((double) Sa) < MagickEpsilon) ||
+                (fabs((double) (Sca-Sa)) < MagickEpsilon))
               {
                 pixel=QuantumRange*(Sa*Da+Sca*(1.0-Da)+Dca*(1.0-Sa));
                 break;
index 512b8ec849a57f64b1d4efa9c28070b70dcd6699..44a1ffb1290b4d0668faebc004653708248fcd19 100644 (file)
@@ -1590,21 +1590,21 @@ MagickExport ChannelFeatures *GetImageFeatures(const Image *image,
         (entropy_x.direction[i].alpha > entropy_y.direction[i].alpha ?
          entropy_x.direction[i].alpha : entropy_y.direction[i].alpha);
     channel_features[RedPixelChannel].measure_of_correlation_2[i]=
-      (sqrt(fabs(1.0-exp(-2.0*(entropy_xy2.direction[i].red-
+      (sqrt(fabs(1.0-exp(-2.0*(double) (entropy_xy2.direction[i].red-
       entropy_xy.direction[i].red)))));
     channel_features[GreenPixelChannel].measure_of_correlation_2[i]=
-      (sqrt(fabs(1.0-exp(-2.0*(entropy_xy2.direction[i].green-
+      (sqrt(fabs(1.0-exp(-2.0*(double) (entropy_xy2.direction[i].green-
       entropy_xy.direction[i].green)))));
     channel_features[BluePixelChannel].measure_of_correlation_2[i]=
-      (sqrt(fabs(1.0-exp(-2.0*(entropy_xy2.direction[i].blue-
+      (sqrt(fabs(1.0-exp(-2.0*(double) (entropy_xy2.direction[i].blue-
       entropy_xy.direction[i].blue)))));
     if (image->colorspace == CMYKColorspace)
       channel_features[BlackPixelChannel].measure_of_correlation_2[i]=
-        (sqrt(fabs(1.0-exp(-2.0*(entropy_xy2.direction[i].black-
+        (sqrt(fabs(1.0-exp(-2.0*(double) (entropy_xy2.direction[i].black-
         entropy_xy.direction[i].black)))));
     if (image->alpha_trait != UndefinedPixelTrait)
       channel_features[AlphaPixelChannel].measure_of_correlation_2[i]=
-        (sqrt(fabs(1.0-exp(-2.0*(entropy_xy2.direction[i].alpha-
+        (sqrt(fabs(1.0-exp(-2.0*(double) (entropy_xy2.direction[i].alpha-
         entropy_xy.direction[i].alpha)))));
   }
   /*
index 73c499528f25a8e6021f5720b4270b52ab47c1d6..42a9695cbb13ff451190f49fdb2ce491e336ee1a 100644 (file)
@@ -331,7 +331,7 @@ static ssize_t PrintChannelLocations(FILE *file,const Image *image,
       if (traits == UndefinedPixelTrait)
         continue;
       offset=GetPixelChannelOffset(image,channel);
-      match=fabs((double) p[offset]-target) < 0.5 ? MagickTrue : MagickFalse;
+      match=fabs((double) (p[offset]-target)) < 0.5 ? MagickTrue : MagickFalse;
       if (match != MagickFalse)
         {
           if ((max_locations != 0) && (n >= (ssize_t) max_locations))
index 19ecff476c07da862058645c387d293f7b383fdf..c776d24c8308fbf217682554e49729d2a751a602 100644 (file)
@@ -6164,7 +6164,8 @@ MagickExport void SetPixelChannelMask(Image *image,
       }
     if (image->alpha_trait != UndefinedPixelTrait)
       {
-        SetPixelChannelTraits(image,channel,UpdatePixelTrait | BlendPixelTrait);
+        SetPixelChannelTraits(image,channel,(const PixelTrait)
+          (UpdatePixelTrait | BlendPixelTrait));
         continue;
       }
     SetPixelChannelTraits(image,channel,UpdatePixelTrait);
index 1707f1a291c30162b21119af7f0f87c929fa0f97..5de7bcf22c05117aa6bdb4e9a5622e11e8503045 100644 (file)
@@ -2251,20 +2251,20 @@ MagickExport MagickBooleanType GetImageQuantizeError(Image *image,
           alpha=(double) (QuantumScale*GetPixelAlpha(image,p));
           beta=(double) (QuantumScale*image->colormap[index].alpha);
         }
-      distance=fabs(alpha*GetPixelRed(image,p)-beta*
-        image->colormap[index].red);
+      distance=fabs((double) (alpha*GetPixelRed(image,p)-beta*
+        image->colormap[index].red));
       mean_error_per_pixel+=distance;
       mean_error+=distance*distance;
       if (distance > maximum_error)
         maximum_error=distance;
-      distance=fabs(alpha*GetPixelGreen(image,p)-beta*
-        image->colormap[index].green);
+      distance=fabs((double) (alpha*GetPixelGreen(image,p)-beta*
+        image->colormap[index].green));
       mean_error_per_pixel+=distance;
       mean_error+=distance*distance;
       if (distance > maximum_error)
         maximum_error=distance;
-      distance=fabs(alpha*GetPixelBlue(image,p)-beta*
-        image->colormap[index].blue);
+      distance=fabs((double) (alpha*GetPixelBlue(image,p)-beta*
+        image->colormap[index].blue));
       mean_error_per_pixel+=distance;
       mean_error+=distance*distance;
       if (distance > maximum_error)
index f892e66129d0ac17c0221417c9165f8d857c526d..dfa27c014de23ae6e2a4359ff47b0b634903ee04 100644 (file)
@@ -48,7 +48,7 @@ extern "C" {
 #define MagickppLibAddendum  "-0"
 #define MagickppLibInterface  1
 #define MagickppLibMinInterface  1
-#define MagickReleaseDate  "2014-12-15"
+#define MagickReleaseDate  "2014-12-21"
 #define MagickChangeDate   "20120427"
 #define MagickAuthoritativeURL  "http://www.imagemagick.org"
 #define MagickFeatures "DPC HDRI OpenMP"
index 43cb8cc4acd6ca177fffc57ef97ea52bf2fb0bd4..00a2b497551bfe3c017a838334b554b6b7126523 100644 (file)
@@ -122,7 +122,7 @@ typedef struct _CCObject
   PointInfo
     centroid;
 
-  size_t
+  double
     area,
     census;
 } CCObject;
@@ -161,20 +161,23 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
     Collect statistics on unique objects.
   */
   object=(CCObject *) AcquireQuantumMemory(number_objects,sizeof(*object));
-  if (object == (CCObject *) NULL) {
-    (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
-      "MemoryAllocationFailed","`%s'",image->filename);
-    return(MagickFalse);
-  }
+  if (object == (CCObject *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),
+        ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+      return(MagickFalse);
+    }
   (void) ResetMagickMemory(object,0,number_objects*sizeof(*object));
-  for (i=0; i < (ssize_t) number_objects; i++) {
+  for (i=0; i < (ssize_t) number_objects; i++)
+  {
     object[i].id=i;
     object[i].bounding_box.x=(ssize_t) image->columns;
     object[i].bounding_box.y=(ssize_t) image->rows;
   }
   status=MagickTrue;
   image_view=AcquireVirtualCacheView(image,exception);
-  for (y=0; y < (ssize_t) image->rows; y++) {
+  for (y=0; y < (ssize_t) image->rows; y++)
+  {
     register const Quantum
       *restrict p;
 
@@ -184,11 +187,13 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
     if (status == MagickFalse)
       continue;
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
-    if (p == (const Quantum *) NULL) {
-      status=MagickFalse;
-      continue;
-    }
-    for (x=0; x < (ssize_t) image->columns; x++) {
+    if (p == (const Quantum *) NULL)
+      {
+        status=MagickFalse;
+        continue;
+      }
+    for (x=0; x < (ssize_t) image->columns; x++)
+    {
       i=(ssize_t) *p;
       if (x < object[i].bounding_box.x)
         object[i].bounding_box.x=x;
@@ -203,7 +208,8 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
     }
   }
   image_view=DestroyCacheView(image_view);
-  for (i=0; i < (ssize_t) number_objects; i++) {
+  for (i=0; i < (ssize_t) number_objects; i++)
+  {
     object[i].bounding_box.width-=(object[i].bounding_box.x-1);
     object[i].bounding_box.height-=(object[i].bounding_box.y-1);
   }
@@ -211,7 +217,11 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
     Merge objects below area threshold.
   */
   image_view=AcquireAuthenticCacheView(image,exception);
-  for (i=0; i < (ssize_t) number_objects; i++) {
+  for (i=0; i < (ssize_t) number_objects; i++)
+  {
+    double
+      census;
+
     RectangleInfo
       bounding_box;
 
@@ -219,7 +229,6 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
       j;
 
     size_t
-      census,
       id;
 
     if (status == MagickFalse)
@@ -229,7 +238,8 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
     for (j=0; j < (ssize_t) number_objects; j++)
       object[j].census=0;
     bounding_box=object[i].bounding_box;
-    for (y=0; y < (ssize_t) bounding_box.height+2; y++) {
+    for (y=0; y < (ssize_t) bounding_box.height+2; y++)
+    {
       register const Quantum
         *restrict p;
 
@@ -240,11 +250,13 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
         continue;
       p=GetCacheViewVirtualPixels(image_view,bounding_box.x-1,bounding_box.y+y-
         1,bounding_box.width+2,1,exception);
-      if (p == (const Quantum *) NULL) {
-        status=MagickFalse;
-        continue;
-      }
-      for (x=0; x < (ssize_t) bounding_box.width+2; x++) {
+      if (p == (const Quantum *) NULL)
+        {
+          status=MagickFalse;
+          continue;
+        }
+      for (x=0; x < (ssize_t) bounding_box.width+2; x++)
+      {
         j=(ssize_t) *p;
         if (j != i)
           object[j].census++;
@@ -254,12 +266,14 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
     census=0;
     id=0;
     for (j=0; j < (ssize_t) number_objects; j++)
-      if ((object[j].area < object[i].area) && (census < object[j].census)) {
-        census=object[j].census;
-        id=(size_t) j;
-      }
+      if ((object[j].area < object[i].area) && (census < object[j].census))
+        {
+          census=object[j].census;
+          id=(size_t) j;
+        }
     object[id].area+=object[i].area;
-    for (y=0; y < (ssize_t) bounding_box.height; y++) {
+    for (y=0; y < (ssize_t) bounding_box.height; y++)
+    {
       register Quantum
         *restrict q;
 
@@ -270,11 +284,13 @@ static MagickBooleanType MergeConnectedComponents(Image *image,
         continue;
       q=GetCacheViewAuthenticPixels(image_view,bounding_box.x,bounding_box.y+y,
         bounding_box.width,1,exception);
-      if (q == (Quantum *) NULL) {
-        status=MagickFalse;
-        continue;
-      }
-      for (x=0; x < (ssize_t) bounding_box.width; x++) {
+      if (q == (Quantum *) NULL)
+        {
+          status=MagickFalse;
+          continue;
+        }
+      for (x=0; x < (ssize_t) bounding_box.width; x++)
+      {
         if ((ssize_t) *q == i)
           *q=(Quantum) id;
         q+=GetPixelChannels(image);
@@ -312,13 +328,15 @@ static MagickBooleanType StatisticsComponentsStatistics(const Image *image,
     Collect statistics on unique objects.
   */
   object=(CCObject *) AcquireQuantumMemory(number_objects,sizeof(*object));
-  if (object == (CCObject *) NULL) {
-    (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
-      "MemoryAllocationFailed","`%s'",image->filename);
-    return(MagickFalse);
-  }
+  if (object == (CCObject *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),
+        ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+      return(MagickFalse);
+    }
   (void) ResetMagickMemory(object,0,number_objects*sizeof(*object));
-  for (i=0; i < (ssize_t) number_objects; i++) {
+  for (i=0; i < (ssize_t) number_objects; i++)
+  {
     object[i].id=i;
     object[i].bounding_box.x=(ssize_t) component_image->columns;
     object[i].bounding_box.y=(ssize_t) component_image->rows;
@@ -327,7 +345,8 @@ static MagickBooleanType StatisticsComponentsStatistics(const Image *image,
   status=MagickTrue;
   image_view=AcquireVirtualCacheView(image,exception);
   component_view=AcquireVirtualCacheView(component_image,exception);
-  for (y=0; y < (ssize_t) image->rows; y++) {
+  for (y=0; y < (ssize_t) image->rows; y++)
+  {
     register const Quantum
       *restrict p,
       *restrict q;
@@ -340,11 +359,13 @@ static MagickBooleanType StatisticsComponentsStatistics(const Image *image,
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     q=GetCacheViewVirtualPixels(component_view,0,y,component_image->columns,1,
       exception);
-    if ((p == (const Quantum *) NULL) || (q == (const Quantum *) NULL)) {
-      status=MagickFalse;
-      continue;
-    }
-    for (x=0; x < (ssize_t) image->columns; x++) {
+    if ((p == (const Quantum *) NULL) || (q == (const Quantum *) NULL))
+      {
+        status=MagickFalse;
+        continue;
+      }
+    for (x=0; x < (ssize_t) image->columns; x++)
+    {
       i=(ssize_t) *q;
       if (x < object[i].bounding_box.x)
         object[i].bounding_box.x=x;
@@ -366,14 +387,15 @@ static MagickBooleanType StatisticsComponentsStatistics(const Image *image,
       q+=GetPixelChannels(component_image);
     }
   }
-  for (i=0; i < (ssize_t) number_objects; i++) {
+  for (i=0; i < (ssize_t) number_objects; i++)
+  {
     object[i].bounding_box.width-=(object[i].bounding_box.x-1);
     object[i].bounding_box.height-=(object[i].bounding_box.y-1);
-    object[i].color.red=ClampToQuantum(object[i].color.red/object[i].area);
-    object[i].color.green=ClampToQuantum(object[i].color.green/object[i].area);
-    object[i].color.blue=ClampToQuantum(object[i].color.blue/object[i].area);
-    object[i].color.alpha=ClampToQuantum(object[i].color.alpha/object[i].area);
-    object[i].color.black=ClampToQuantum(object[i].color.black/object[i].area);
+    object[i].color.red=object[i].color.red/object[i].area;
+    object[i].color.green=object[i].color.green/object[i].area;
+    object[i].color.blue=object[i].color.blue/object[i].area;
+    object[i].color.alpha=object[i].color.alpha/object[i].area;
+    object[i].color.black=object[i].color.black/object[i].area;
     object[i].centroid.x=object[i].centroid.x/object[i].area;
     object[i].centroid.y=object[i].centroid.y/object[i].area;
   }
@@ -385,7 +407,8 @@ static MagickBooleanType StatisticsComponentsStatistics(const Image *image,
   qsort((void *) object,number_objects,sizeof(*object),CCObjectCompare);
   (void) fprintf(stdout,
     "Objects (id: bounding-box centroid area mean-color):\n");
-  for (i=0; i < (ssize_t) number_objects; i++) {
+  for (i=0; i < (ssize_t) number_objects; i++)
+  {
     char
       mean_color[MaxTextExtent];
 
@@ -455,23 +478,26 @@ MagickExport Image *ConnectedComponentsImage(const Image *image,
   component_image->depth=MAGICKCORE_QUANTUM_DEPTH;
   component_image->colorspace=GRAYColorspace;
   status=SetImageStorageClass(component_image,DirectClass,exception);
-  if (status == MagickFalse) {
-    component_image=DestroyImage(component_image);
-    return((Image *) NULL);
-  }
+  if (status == MagickFalse)
+    {
+      component_image=DestroyImage(component_image);
+      return((Image *) NULL);
+    }
   /*
     Initialize connected components equivalences.
   */
   size=image->columns*image->rows;
-  if (image->columns != (size/image->rows)) {
-    component_image=DestroyImage(component_image);
-    ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
-  }
+  if (image->columns != (size/image->rows))
+    {
+      component_image=DestroyImage(component_image);
+      ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
+    }
   equivalences=AcquireMatrixInfo(size,1,sizeof(ssize_t),exception);
-  if (equivalences == (MatrixInfo *) NULL) {
-    component_image=DestroyImage(component_image);
-    return((Image *) NULL);
-  }
+  if (equivalences == (MatrixInfo *) NULL)
+    {
+      component_image=DestroyImage(component_image);
+      return((Image *) NULL);
+    }
   for (n=0; n < (ssize_t) (image->columns*image->rows); n++)
     status=SetMatrixElement(equivalences,n,0,&n);
   /*
@@ -480,7 +506,8 @@ MagickExport Image *ConnectedComponentsImage(const Image *image,
   status=MagickTrue;
   progress=0;
   image_view=AcquireVirtualCacheView(image,exception);
-  for (n=0; n < (ssize_t) (connectivity > 4 ? 4 : 2); n++) {
+  for (n=0; n < (ssize_t) (connectivity > 4 ? 4 : 2); n++)
+  {
     ssize_t
       connect4[2][2] = { { -1,  0 }, {  0, -1 } },
       connect8[4][2] = { { -1, -1 }, { -1,  0 }, { -1,  1 }, {  0, -1 } },
@@ -491,7 +518,8 @@ MagickExport Image *ConnectedComponentsImage(const Image *image,
       continue;
     dy=connectivity > 4 ? connect8[n][0] : connect4[n][0];
     dx=connectivity > 4 ? connect8[n][1] : connect4[n][1];
-    for (y=0; y < (ssize_t) image->rows; y++) {
+    for (y=0; y < (ssize_t) image->rows; y++)
+    {
       register const Quantum
         *restrict p;
 
@@ -501,12 +529,14 @@ MagickExport Image *ConnectedComponentsImage(const Image *image,
       if (status == MagickFalse)
         continue;
       p=GetCacheViewVirtualPixels(image_view,0,y-1,image->columns,3,exception);
-      if (p == (const Quantum *) NULL) {
-        status=MagickFalse;
-        continue;
-      }
+      if (p == (const Quantum *) NULL)
+        {
+          status=MagickFalse;
+          continue;
+        }
       p+=GetPixelChannels(image)*image->columns;
-      for (x=0; x < (ssize_t) image->columns; x++) {
+      for (x=0; x < (ssize_t) image->columns; x++)
+      {
         PixelInfo
           pixel,
           target;
@@ -528,10 +558,11 @@ MagickExport Image *ConnectedComponentsImage(const Image *image,
         GetPixelInfoPixel(image,p+neighbor_offset,&target);
         if (((x+dx) < 0) || ((x+dx) >= (ssize_t) image->columns) ||
             ((y+dy) < 0) || ((y+dy) >= (ssize_t) image->rows) ||
-            (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse)) {
-          p+=GetPixelChannels(image);
-          continue;
-        }
+            (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse))
+          {
+            p+=GetPixelChannels(image);
+            continue;
+          }
         /*
           Resolve this equivalence.
         */
@@ -539,32 +570,39 @@ MagickExport Image *ConnectedComponentsImage(const Image *image,
         neighbor_offset=dy*image->columns+dx;
         ox=offset;
         status=GetMatrixElement(equivalences,ox,0,&object);
-        while (object != ox) {
+        while (object != ox)
+        {
           ox=object;
           status=GetMatrixElement(equivalences,ox,0,&object);
         }
         oy=offset+neighbor_offset;
         status=GetMatrixElement(equivalences,oy,0,&object);
-        while (object != oy) {
+        while (object != oy)
+        {
           oy=object;
           status=GetMatrixElement(equivalences,oy,0,&object);
         }
-        if (ox < oy) {
-          status=SetMatrixElement(equivalences,oy,0,&ox);
-          root=ox;
-        } else {
-          status=SetMatrixElement(equivalences,ox,0,&oy);
-          root=oy;
-        }
+        if (ox < oy)
+          {
+            status=SetMatrixElement(equivalences,oy,0,&ox);
+            root=ox;
+          }
+        else
+          {
+            status=SetMatrixElement(equivalences,ox,0,&oy);
+            root=oy;
+          }
         ox=offset;
         status=GetMatrixElement(equivalences,ox,0,&object);
-        while (object != root) {
+        while (object != root)
+        {
           status=GetMatrixElement(equivalences,ox,0,&object);
           status=SetMatrixElement(equivalences,ox,0,&root);
         }
         oy=offset+neighbor_offset;
         status=GetMatrixElement(equivalences,oy,0,&object);
-        while (object != root) {
+        while (object != root)
+        {
           status=GetMatrixElement(equivalences,oy,0,&object);
           status=SetMatrixElement(equivalences,oy,0,&root);
         }
@@ -579,7 +617,8 @@ MagickExport Image *ConnectedComponentsImage(const Image *image,
   */
   n=0;
   component_view=AcquireAuthenticCacheView(component_image,exception);
-  for (y=0; y < (ssize_t) component_image->rows; y++) {
+  for (y=0; y < (ssize_t) component_image->rows; y++)
+  {
     register Quantum
       *restrict q;
 
@@ -590,46 +629,53 @@ MagickExport Image *ConnectedComponentsImage(const Image *image,
       continue;
     q=QueueCacheViewAuthenticPixels(component_view,0,y,component_image->columns,
       1,exception);
-    if (q == (Quantum *) NULL) {
-      status=MagickFalse;
-      continue;
-    }
-    for (x=0; x < (ssize_t) component_image->columns; x++) {
+    if (q == (Quantum *) NULL)
+      {
+        status=MagickFalse;
+        continue;
+      }
+    for (x=0; x < (ssize_t) component_image->columns; x++)
+    {
       ssize_t
         object,
         offset;
 
       offset=y*image->columns+x;
       status=GetMatrixElement(equivalences,offset,0,&object);
-      if (object == offset) {
-        object=n++;
-        status=SetMatrixElement(equivalences,offset,0,&object);
-      } else {
-        status=GetMatrixElement(equivalences,object,0,&object);
-        status=SetMatrixElement(equivalences,offset,0,&object);
-      }
+      if (object == offset)
+        {
+          object=n++;
+          status=SetMatrixElement(equivalences,offset,0,&object);
+        }
+      else
+        {
+          status=GetMatrixElement(equivalences,object,0,&object);
+          status=SetMatrixElement(equivalences,offset,0,&object);
+        }
       *q=(Quantum) (object > (ssize_t) QuantumRange ? (ssize_t) QuantumRange :
         object);
       q+=GetPixelChannels(component_image);
     }
     if (SyncCacheViewAuthenticPixels(component_view,exception) == MagickFalse)
       status=MagickFalse;
-    if (image->progress_monitor != (MagickProgressMonitor) NULL) {
-      MagickBooleanType
-        proceed;
-
-      proceed=SetImageProgress(image,ConnectedComponentsImageTag,progress++,
-        image->rows);
-      if (proceed == MagickFalse)
-        status=MagickFalse;
-    }
+    if (image->progress_monitor != (MagickProgressMonitor) NULL)
+      {
+        MagickBooleanType
+          proceed;
+
+        proceed=SetImageProgress(image,ConnectedComponentsImageTag,progress++,
+          image->rows);
+        if (proceed == MagickFalse)
+          status=MagickFalse;
+      }
   }
   component_view=DestroyCacheView(component_view);
   equivalences=DestroyMatrixInfo(equivalences);
-  if (n > QuantumRange) {
-    component_image=DestroyImage(component_image);
-    ThrowImageException(ResourceLimitError,"TooManyObjects");
-  }
+  if (n > (ssize_t) QuantumRange)
+    {
+      component_image=DestroyImage(component_image);
+      ThrowImageException(ResourceLimitError,"TooManyObjects");
+    }
   artifact=GetImageArtifact(image,"connected-components:area-threshold");
   area_threshold=0.0;
   if (artifact != (const char *) NULL)
index e9c4d0c2b764bdf39bc12bff83008c7e4328f720..a2f0245c2df3476227d94d7fe2ff6caf76bd5dab 100644 (file)
@@ -373,7 +373,7 @@ static ssize_t PrintChannelLocations(FILE *file,const Image *image,
       if (traits == UndefinedPixelTrait)
         continue;
       offset=GetPixelChannelOffset(image,channel);
-      match=fabs((double) p[offset]-target) < 0.5 ? MagickTrue : MagickFalse;
+      match=fabs((double) (p[offset]-target)) < 0.5 ? MagickTrue : MagickFalse;
       if (match != MagickFalse)
         {
           if ((max_locations != 0) && (n >= (ssize_t) max_locations))