[LAB Space] Avg Color via 1x1 Scaling Bug Due to Forgot Sign
Posted: 2012-06-30T00:41:29-07:00
ImageMagick 6.7.8-0, libtiff 4.0.2.
In the LAB colorspace, .green() values of [0, 0.996109] are translated into A* values by multiplying the 0-1 decimals by 256 (possibly 255, but I think 256), and if that is 128 or more, subtracting 256. Therefore, the A* values are translated into [0, -0.996096]. (Yes, it looks like we almost just made the value negative, but that's coincidence. 0.996109*256-256 = -0.996096.)
A* values of 0 and -0.996096 are the same, assuming you're not worried about variations less than 1 in A*.
There are 1,145 pixels with A* of 0, and 2,455 pixels with -0.996096. Therefore, they should average to -0.67928.
Instead, when scaling to 1 pixel, the original decimals are being averaged, ignoring that 0 and 0.996109 are right next to each other, due to the wrapping. These decimals are averaged to 67.9286%, which when translated to A* becomes -82.102784, which is no where near any of the colors in the original image.
NOTE: All of these colors are virtually identical in LAB colorspace, due to the wrapping nature at 0 and 1 to positive and negative values in A*.
Download this file at: http://www.filedropper.com/60x60 - You can only see slight variation in color with a well calibrated monitor, they're reasonably all the same color.
Download this file at: http://www.filedropper.com/1x1 - You get a bright green, which isn't correct.
In the LAB colorspace, .green() values of [0, 0.996109] are translated into A* values by multiplying the 0-1 decimals by 256 (possibly 255, but I think 256), and if that is 128 or more, subtracting 256. Therefore, the A* values are translated into [0, -0.996096]. (Yes, it looks like we almost just made the value negative, but that's coincidence. 0.996109*256-256 = -0.996096.)
A* values of 0 and -0.996096 are the same, assuming you're not worried about variations less than 1 in A*.
There are 1,145 pixels with A* of 0, and 2,455 pixels with -0.996096. Therefore, they should average to -0.67928.
Instead, when scaling to 1 pixel, the original decimals are being averaged, ignoring that 0 and 0.996109 are right next to each other, due to the wrapping. These decimals are averaged to 67.9286%, which when translated to A* becomes -82.102784, which is no where near any of the colors in the original image.
NOTE: All of these colors are virtually identical in LAB colorspace, due to the wrapping nature at 0 and 1 to positive and negative values in A*.
Download this file at: http://www.filedropper.com/60x60 - You can only see slight variation in color with a well calibrated monitor, they're reasonably all the same color.
Scale to 1x1 px, and you get:Histogram:
51: (16192, 0, 2304) #3F4000000900 cielab(24.7074%,0%,3.51568%)
389: (16192, 0, 2560) #3F4000000A00 cielab(24.7074%,0%,3.90631%)
111: (16192,65280, 2304) #3F40FF000900 cielab(24.7074%,99.6109%,3.51568%)
801: (16192,65280, 2560) #3F40FF000A00 cielab(24.7074%,99.6109%,3.90631%)
94: (16448, 0, 2304) #404000000900 cielab(25.098%,0%,3.51568%)
611: (16448, 0, 2560) #404000000A00 cielab(25.098%,0%,3.90631%)
168: (16448,65280, 2304) #4040FF000900 cielab(25.098%,99.6109%,3.51568%)
1375: (16448,65280, 2560) #4040FF000A00 cielab(25.098%,99.6109%,3.90631%)
Download this file at: http://www.filedropper.com/1x1 - You get a bright green, which isn't correct.
Histogram:
1: (16352,44517, 2530) #3FE0ADE509E2 cielab(24.9516%, 67.9286%, 3.86053%)