Changed Surface blur diameter to radius #1978
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that the Diameter input of the Surface Blur node (#1292) behaved weirdly. In my testing, I set both sigmas to 1000 (max), which makes the node behave like a simple Gaussian blur. This makes it easy to see the effects of the diameter. I saw that D=1,2,3 produced the same image. Same with D=4,5 and D=6,7 etc. In general, only odd numbers >=3 were actually used by OpenCV's
bilateralFilter
.To fix this, I switched to radius instead. The diameter is then calculated as 2r+1. This makes the node behave as expected and is consistent with all other blur nodes. I also set 100 as the max radius, because Surface blur is extremely slow for large radii (anything R>30 takes multiple seconds at 100% CPU on all cores).
Since both linear and log scale didn't feel right for the radius slider, I added a new sqrt scale. We can use this scale for other stuff in the future, but it's only used here right now.
Migration: Since this change is breaking, I added a migration. Migrating input values is easy, but connections are hard.
In fact, 3 nodes necessary to approximately convert from diameter to radius (D=1 is incorrectly mapped to R=0):
And it takes 6 nodes for a correct conversion:
Do I have to code up a migration for connections, or can we just list this under "breaking changes" in the next release?