diff --git a/MagickCore/histogram.c b/MagickCore/histogram.c
index 60f0ec4..04695fe 100644
--- a/MagickCore/histogram.c
+++ b/MagickCore/histogram.c
@@ -1014,10 +1014,14 @@
     ChannelType
       channel_mask;
 
+    PixelChannel
+      channel;
+
     PixelTrait
       traits;
 
-    traits=GetPixelChannelMapTraits(image,i);
+    channel=GetPixelChannelMapChannel(image,i);
+    traits=GetPixelChannelMapTraits(image,channel);
     if ((traits & UpdatePixelTrait) == 0)
       continue;
     channel_mask=SetPixelChannelMask(image,(ChannelType) (1 << i));