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

Optimized box blur #2325

Merged
merged 1 commit into from
Nov 10, 2023
Merged

Conversation

RunDevelopment
Copy link
Member

I noticed that our box blur was slower than gauss for large radii, so I know that something was wrong. We were using a cv2.filter2D based box blur. While this is correct, it's not ideal for performance. Box blur is a highly optimizable filter, so cv2.filter2D is far too general.

I used cv2.blur (which implements a highly optimized box blur) whenever possible. Since cv2.blur only supports integer radii, I only use it when the radii are integers and when the radii are so large that the difference between N.5 and N is not noticeable.

With my 2k example image, the box blur node takes this long:

Radius Old (s) New (s) Change
3 0.051 0.051 1x
6 0.058 0.058 1x
10 0.067 0.06 1.1x
20 0.062 0.062 1x
50 0.11 0.062 1.8x
100 0.61 0.065 9.4x
500 0.91 0.083 11x
1000 1.2 0.1 12x

@joeyballentine joeyballentine merged commit 4660d71 into chaiNNer-org:main Nov 10, 2023
@RunDevelopment RunDevelopment deleted the opt-box-blur branch November 10, 2023 22:08
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.

2 participants