Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed blur filter throwing exception for too large values relative to image #972

Merged
merged 1 commit into from
Mar 21, 2025

Conversation

Rishab87
Copy link
Contributor

@Rishab87 Rishab87 commented Mar 13, 2025

In this PR I've clamped radius to ensure we calculate maximum allowed blur in case of too large values relative to the image
I've also added a check for sum to make it 1 if it is 0 because it can be still zero in some cases even after clamping.

I tested it for the code provided in the issue and it works without crashing:

void setup() {
  size(100, 100, P3D);
}

void draw() {
  background(0);
  ellipse(50, 50, 80, 80);
  filter(BLUR, 29);
}

Output:
image

Their can be other approaches too, like throwing a meaningful error for the users.

This PR fixes #723

@SableRaf SableRaf requested a review from Stefterv March 13, 2025 09:20
@Stefterv
Copy link
Collaborator

Hi @Rishab87 thank you for your work on this, just a quick question, you are clamping the input value as well as doing a safer divide? Could you explain why do both?

@Rishab87
Copy link
Contributor Author

even after clamping I think their can be few edge cases like when loop would iterate a few times where sum can accumulate to zero though I'm not completely sure about this to be honest

@Stefterv Stefterv added this to the 4.4.1 milestone Mar 13, 2025
@SableRaf SableRaf merged commit ff78d90 into processing:main Mar 21, 2025
11 checks passed
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.

Blur filter throws exception if extent is too large relative to image size
3 participants