Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Dec 22, 2025

def get_on_pixels(self, image: Image.Image) -> list[tuple[int, int]]:
"""Get a list of all turned on pixels in a binary image
Returns a list of tuples of (x,y) coordinates
of all matching pixels. See :ref:`coordinate-system`."""
if image.mode != "L":
msg = "Image mode must be L"

I expect 'a binary image' to mean a 1 mode image, not an L mode image. Considering the nature of get_on_pixels(), looking for pixels that are non-zero, I think the original intention was for this to be used with 1 mode images, and accepting L mode images was a misunderstanding.

#691

It is used to apply morphological operators on PIL images of mode 'L' where each pixel is considered binary

But I expect that we don't want to remove long-established functionality, so this PR allows for both 1 and L mode images.

I've also added this functionality to apply() and match().

@radarhere radarhere force-pushed the imagemorph_get_on_pixels branch from 23ea364 to 40fcf77 Compare December 22, 2025 23:56
@radarhere radarhere changed the title Allow 1 mode images in MorphOp get_on_pixels() Allow 1 mode images in MorphOp Dec 22, 2025
@radarhere radarhere force-pushed the imagemorph_get_on_pixels branch 2 times, most recently from 09c0930 to 150a26b Compare December 23, 2025 02:11
@radarhere radarhere force-pushed the imagemorph_get_on_pixels branch from 150a26b to a704711 Compare December 23, 2025 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant