2bit-pxlr-studio
2bit-pxlr-studio copied to clipboard
Issue with the calculation of pixels in Histogram
Two issues in 1:
- A pure black image returns 1792 white pixels. I suppose that it is due to the fact that a 128x128 area is covered instead of a 128x112. So this also contains the "black pixels area" which should not be included (they appear white in real despite their name). The sum of pixels is 16128 as expected ;
- A pure white image returns 32512 white pixels which is not at all the sum expected for a 128x128 image ;
So the way the white pixels are counted is sometimes not accurate and the calculation should be restricted to a 128x112 image.
I however do not see any obvious issue in void createHistogram() apart that I do not found what bitsSetLUT does (I think a sum of the bits into the byte ?).
Oh, got it, Histogram is declared as uint8_t, there may be an overflow somewhere and it should be uin16_t for sum of pixel values. I wonder how it could work sometimes.