Skip to content

Clip ModeFilter window to the image - #10607

Merged
radarhere merged 3 commits into
mainfrom
modefilter-clip-window
Nov 24, 2026
Merged

radarhere merged 3 commits into
mainfrom
modefilter-clip-window

Conversation

@aclark4life

Copy link
Copy Markdown
Member

ImagingModeFilter() visited every position in the size × size window around each pixel and skipped the ones outside the image, so the time grew with size even when the image is tiny. For example, ModeFilter(16777217) on a 3x3 image took 0.22 s, and ModeFilter(2**31 - 1) takes about 30 s.

This clips the window to the image before counting pixels, so the work depends only on the image. It also releases the GIL while filtering, as other filters do.

🤖 Generated with Claude Code

Only count pixels inside the image, rather than visiting every position
in the window and skipping those outside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@radarhere
radarhere enabled auto-merge (squash) November 24, 2026 00:39
@radarhere
radarhere merged commit cd7c8ab into main Nov 24, 2026
129 of 132 checks passed
@radarhere
radarhere deleted the modefilter-clip-window branch November 24, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants