]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Wed, 15 Jan 2014 00:54:40 +0000 (00:54 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Wed, 15 Jan 2014 00:54:40 +0000 (00:54 +0000)
MagickCore/segment.c

index 5f3d912e82b720a865e9052c291c5c0fc64e9b90..771eb113261f851f50292b006ea17f2d0e68d37d 100644 (file)
@@ -1186,15 +1186,18 @@ MagickExport MagickBooleanType GetImageDynamicThreshold(const Image *image,
         cluster=cluster->next;
       }
     }
-  threshold=(background->red.center+object->red.center)/2.0;
-  pixel->red=(double) ScaleCharToQuantum((unsigned char)
-    (threshold+0.5));
-  threshold=(background->green.center+object->green.center)/2.0;
-  pixel->green=(double) ScaleCharToQuantum((unsigned char)
-    (threshold+0.5));
-  threshold=(background->blue.center+object->blue.center)/2.0;
-  pixel->blue=(double) ScaleCharToQuantum((unsigned char)
-    (threshold+0.5));
+  if (background != (Cluster *) NULL)
+    {
+      threshold=(background->red.center+object->red.center)/2.0;
+      pixel->red=(double) ScaleCharToQuantum((unsigned char)
+        (threshold+0.5));
+      threshold=(background->green.center+object->green.center)/2.0;
+      pixel->green=(double) ScaleCharToQuantum((unsigned char)
+        (threshold+0.5));
+      threshold=(background->blue.center+object->blue.center)/2.0;
+      pixel->blue=(double) ScaleCharToQuantum((unsigned char)
+        (threshold+0.5));
+    }
   /*
     Relinquish resources.
   */