2bit-pxlr-studio icon indicating copy to clipboard operation
2bit-pxlr-studio copied to clipboard

Issue with the calculation of pixels in Histogram

Open Raphael-Boichot opened this issue 2 years ago • 2 comments

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.

Raphael-Boichot avatar Jun 18 '22 07:06 Raphael-Boichot

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 ?).

Raphael-Boichot avatar Jun 18 '22 09:06 Raphael-Boichot

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.

Raphael-Boichot avatar Jun 18 '22 09:06 Raphael-Boichot