### ImageMagick version

7.1.1-20 and older

### Operating system

Windows

### Operating system, version and so on

Windows 11

### Description

Channel statistics are collected only for channels that have the UpdatePixelTrait set. So when `-channel` is used, some statistics will be wrong. I can't see a good reason for this, and it seems to be a bug.


### Steps to Reproduce

For example:
```
magick xc:sRGB(10%,20%,30%) -channel R -verbose info:
```
The output includes:
```
    Red:
      min: 4.2949673e+08  (0.1)
      max: 4.2949673e+08 (0.1)
      mean: 4.2949673e+08 (0.1)
      median: 4.2949673e+08 (0.1)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: -3.4359738e+46
      entropy: 0
    Green:
      min: 1.7976931e+308  (4.1855805e+298)
      max: -1.7976931e+308 (-4.1855805e+298)
      mean: 0 (0)
      median: 0 (0)
      standard deviation: -0 (-0)
      kurtosis: -3
      skewness: 0
      entropy: 0
    Blue:
      min: 1.7976931e+308  (4.1855805e+298)
      max: -1.7976931e+308 (-4.1855805e+298)
      mean: 0 (0)
      median: 0 (0)
      standard deviation: -0 (-0)
      kurtosis: -3
      skewness: 0
      entropy: 0
```
The statistics for the Green and Blue channels are wrong.

Another example: we try to set the G channel to the mean of the values in the red channel:
```
magick xc:sRGB(10%,20%,30%)  -channel G -fx "mean.r" +channel txt:
# ImageMagick pixel enumeration: 1,1,0,65535,srgb
0,0: (6554,0,19661)  #199A00004CCD  srgb(10%,0%,30%)
```
The result is wrong, because statistics were not collected for the Red channel, so the value of `0` was used.

These problems are fixed by the following patch to statistic.c:
```
--- "magickcore\\statistic20231110.c"	2023-10-03 13:13:34.844838100 +0100
+++ "magickcore\\statistic.c"	2023-11-10 10:35:41.046378900 +0000
@@ -1513,8 +1513,6 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
         M00[channel]+=QuantumScale*(double) p[i];
         M00[MaxPixelChannels]+=QuantumScale*(double) p[i];
         M10[channel]+=x*QuantumScale*(double) p[i];
@@ -1558,8 +1556,6 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
         M11[channel]+=(x-centroid[channel].x)*(y-centroid[channel].y)*
           QuantumScale*(double) p[i];
         M11[MaxPixelChannels]+=(x-centroid[channel].x)*(y-centroid[channel].y)*
@@ -1894,9 +1890,7 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
-				if (row_initialize != MagickFalse)
+	if (row_initialize != MagickFalse)
           {
             row_minima=(double) p[i];
             row_maxima=(double) p[i];
@@ -2106,8 +2100,6 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
         if (channel_statistics[channel].depth != MAGICKCORE_QUANTUM_DEPTH)
           {
             depth=channel_statistics[channel].depth;
@@ -2242,8 +2234,6 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           const Quantum
```


### Images

N/A
Channel statistics
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : Channel statistics
Issue date:

--- start body ---
### ImageMagick version

7.1.1-20 and older

### Operating system

Windows

### Operating system, version and so on

Windows 11

### Description

Channel statistics are collected only for channels that have the UpdatePixelTrait set. So when `-channel` is used, some statistics will be wrong. I can't see a good reason for this, and it seems to be a bug.


### Steps to Reproduce

For example:
```
magick xc:sRGB(10%,20%,30%) -channel R -verbose info:
```
The output includes:
```
    Red:
      min: 4.2949673e+08  (0.1)
      max: 4.2949673e+08 (0.1)
      mean: 4.2949673e+08 (0.1)
      median: 4.2949673e+08 (0.1)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: -3.4359738e+46
      entropy: 0
    Green:
      min: 1.7976931e+308  (4.1855805e+298)
      max: -1.7976931e+308 (-4.1855805e+298)
      mean: 0 (0)
      median: 0 (0)
      standard deviation: -0 (-0)
      kurtosis: -3
      skewness: 0
      entropy: 0
    Blue:
      min: 1.7976931e+308  (4.1855805e+298)
      max: -1.7976931e+308 (-4.1855805e+298)
      mean: 0 (0)
      median: 0 (0)
      standard deviation: -0 (-0)
      kurtosis: -3
      skewness: 0
      entropy: 0
```
The statistics for the Green and Blue channels are wrong.

Another example: we try to set the G channel to the mean of the values in the red channel:
```
magick xc:sRGB(10%,20%,30%)  -channel G -fx "mean.r" +channel txt:
# ImageMagick pixel enumeration: 1,1,0,65535,srgb
0,0: (6554,0,19661)  #199A00004CCD  srgb(10%,0%,30%)
```
The result is wrong, because statistics were not collected for the Red channel, so the value of `0` was used.

These problems are fixed by the following patch to statistic.c:
```
--- "magickcore\\statistic20231110.c"	2023-10-03 13:13:34.844838100 +0100
+++ "magickcore\\statistic.c"	2023-11-10 10:35:41.046378900 +0000
@@ -1513,8 +1513,6 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
         M00[channel]+=QuantumScale*(double) p[i];
         M00[MaxPixelChannels]+=QuantumScale*(double) p[i];
         M10[channel]+=x*QuantumScale*(double) p[i];
@@ -1558,8 +1556,6 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
         M11[channel]+=(x-centroid[channel].x)*(y-centroid[channel].y)*
           QuantumScale*(double) p[i];
         M11[MaxPixelChannels]+=(x-centroid[channel].x)*(y-centroid[channel].y)*
@@ -1894,9 +1890,7 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
-				if (row_initialize != MagickFalse)
+	if (row_initialize != MagickFalse)
           {
             row_minima=(double) p[i];
             row_maxima=(double) p[i];
@@ -2106,8 +2100,6 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
         if (channel_statistics[channel].depth != MAGICKCORE_QUANTUM_DEPTH)
           {
             depth=channel_statistics[channel].depth;
@@ -2242,8 +2234,6 @@
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if ((traits & UpdatePixelTrait) == 0)
-          continue;
         for (y=0; y < (ssize_t) image->rows; y++)
         {
           const Quantum
```


### Images

N/A
--- end body ---
