Add softness for Threshold anti-aliasing #2812
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.
While using chainner's Threshold node to sharpen some upscaled text, I noticed that the AA is quite sharp. This is generally good, but I would have liked a bit softer in this case. So I added a high-quality sub-pixel blur to
binary_threshold
by exploiting how it calculates anti-aliased pixel. See chaiNNer-org/chaiNNer-rs#27 for details.This PR adds this new functionality in
chainner_ext
to the Threshold node via the new Softness slider. Users can set the softness as a value between 0 and 10.I limited the slider to 11 values, because the blur is very subtle. A softness of 10 is roughly equivalent to a box blur of radius 0.3, and 5 roughly corresponds to 0.15. So having many in-between values wouldn't be useful.