diff --git a/MagickCore/compare.c b/MagickCore/compare.c
index 1fd4a58..adfbb08 100644
--- a/MagickCore/compare.c
+++ b/MagickCore/compare.c
@@ -1154,7 +1154,7 @@
       i;
 
     difference=0.0;
-    for (i=0; i < 7; i++)
+    for (i=0; i < MaximumNumberOfImageMoments; i++)
     {
       double
         alpha,
@@ -1185,7 +1185,7 @@
       i;
 
     difference=0.0;
-    for (i=0; i < 7; i++)
+    for (i=0; i < MaximumNumberOfImageMoments; i++)
     {
       double
         alpha,
@@ -1210,8 +1210,6 @@
   return(MagickTrue);
 }
 
-
-
 static MagickBooleanType GetRootMeanSquaredDistortion(const Image *image,
   const Image *reconstruct_image,double *distortion,ExceptionInfo *exception)
 {
diff --git a/MagickCore/identify.c b/MagickCore/identify.c
index 76ecb2b..a5ea189 100644
--- a/MagickCore/identify.c
+++ b/MagickCore/identify.c
@@ -375,7 +375,7 @@
     GetMagickPrecision(),pow(scale,powers[0])*
     channel_moments[channel].ellipse_intensity,GetMagickPrecision(),
     channel_moments[channel].ellipse_intensity);
-  for (i=0; i < 8; i++)
+  for (i=0; i < MaximumNumberOfImageMoments; i++)
     n+=FormatLocaleFile(file,"      I%.20g: %.*g (%.*g)\n",i+1.0,
       GetMagickPrecision(),channel_moments[channel].I[i]/pow(scale,powers[i]),
       GetMagickPrecision(),channel_moments[channel].I[i]);
@@ -392,7 +392,7 @@
     n;
 
   n=FormatLocaleFile(file,"    %s:\n",name);
-  for (i=0; i < 7; i++)
+  for (i=0; i < MaximumNumberOfImageMoments; i++)
     n+=FormatLocaleFile(file,"      PH%.20g: %.*g, %.*g\n",i+1.0,
       GetMagickPrecision(),channel_phash[channel].srgb_hu_phash[i],
       GetMagickPrecision(),channel_phash[channel].hclp_hu_phash[i]);
diff --git a/MagickCore/statistic.c b/MagickCore/statistic.c
index bd3f9b9..776624c 100644
--- a/MagickCore/statistic.c
+++ b/MagickCore/statistic.c
@@ -1748,7 +1748,7 @@
   if (perceptual_hash == (ChannelPerceptualHash *) NULL)
     return((ChannelPerceptualHash *) NULL);
   for (channel=0; channel <= MaxPixelChannels; channel++)
-    for (i=0; i < 7; i++)
+    for (i=0; i < MaximumNumberOfImageMoments; i++)
       perceptual_hash[channel].srgb_hu_phash[i]=
         (-MagickLog10(moments[channel].I[i]));
   moments=(ChannelMoments *) RelinquishMagickMemory(moments);
@@ -1779,7 +1779,7 @@
       return((ChannelPerceptualHash *) NULL);
     }
   for (channel=0; channel <= MaxPixelChannels; channel++)
-    for (i=0; i < 7; i++)
+    for (i=0; i < MaximumNumberOfImageMoments; i++)
       perceptual_hash[channel].hclp_hu_phash[i]=
         (-MagickLog10(moments[channel].I[i]));
   moments=(ChannelMoments *) RelinquishMagickMemory(moments);
diff --git a/MagickCore/statistic.h b/MagickCore/statistic.h
index 5cfceb2..6017bf7 100644
--- a/MagickCore/statistic.h
+++ b/MagickCore/statistic.h
@@ -22,6 +22,8 @@
 extern "C" {
 #endif
 
+#define MaximumNumberOfImageMoments  8
+
 typedef struct _ChannelStatistics
 {
   size_t
@@ -45,7 +47,7 @@
 typedef struct _ChannelMoments
 {
   double
-    I[32];
+    I[MaximumNumberOfImageMoments+1];
 
   PointInfo
     centroid,
@@ -60,8 +62,8 @@
 typedef struct _ChannelPerceptualHash
 {
   double
-    srgb_hu_phash[32],
-    hclp_hu_phash[32];
+    srgb_hu_phash[MaximumNumberOfImageMoments+1],
+    hclp_hu_phash[MaximumNumberOfImageMoments+1];
 } ChannelPerceptualHash;
 
 typedef enum