PNG-spec icon indicating copy to clipboard operation
PNG-spec copied to clipboard

Filtering description confussion

Open Ciubix8513 opened this issue 2 months ago • 2 comments

I feel that the description of the filtering process is described in a confusing way. The beginning of 9.2 states:

Filters are applied to bytes, not to pixels, regardless of the bit depth or color type of the image.

However in the table right bellow it:

a the byte corresponding to x in the pixel immediately before the pixel containing x (or the byte immediately before x, when the bit depth is less than 8);

To me this feels incredibly confusing and self contradicting. I got caught up on this wording quite a few times personally.

Ciubix8513 avatar Oct 15 '25 13:10 Ciubix8513

I believe I understand and agree. It says filtering doesn't related to pixels, but then immediately references pixel locations.

I'm struggling to think of a more clear way to convey the information. I'm open to suggestions. Maybe something like "backwards in the decompressed IDAT data stream by (bit depth / 8) bytes". There has to be a better way to say this. And that's only for the "left" reference. "Up" and "up left" references will be even harder to describe.

I think a better approach is to say that filters may reference neighboring pixels, but that each byte of a pixel is referenced separately. This only applies when the bit depth is >8 bit. So the high byte of pixel 'x' references the high byte of pixel 'a'.

ProgramMax avatar Oct 16 '25 08:10 ProgramMax

I think a better approach is to say that filters may reference neighboring pixels, but that each byte of a pixel is referenced separately. This only applies when the bit depth is >8 bit. So the high byte of pixel 'x' references the high byte of pixel 'a'.

I agree that this is a conceptually cleaner way to address the issue. Probably adding another diagram, with a 16bit sample depth, would help as well.

svgeesus avatar Oct 28 '25 22:10 svgeesus