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.
This PR makes a minor improvement to
convenient_upscale
(and therefor all upscaling nodes).When computing alpha using the black and white image upscales, we get 3 channels that all represent the computed alpha. We previously simply took the mean of those 3 and called it a day, but we can do better. By using the mean to interpolate between the min and max of those 3 channels, we get a lot better results near 0 and 1.
Why? If we model AI upscaling as simply adding noise to the true high-res alpha, then it makes sense that the mean of 3 noisy versions of the same image will never give us true 0 or 1. The mean will always be slightly above 0 and slightly below 1. By using the mean to interpolate between the min and max, we can get much closer to true 0 and 1.
However, the tradeoff is that we also get more noise. Since fluctuations in min and max will now affect the output a lot, we will get more noise in the final alpha. This noise is of course bounded by the amount of noise the upscaler produces, so it's not too bad in practice.
Examples
Here are some non-cherry-picked examples. The images were DDS compressed and contained either binary alpha or full alpha with clearly defined edges. They were upscaled 4x using either UltraSharp or AnimeSharp. The output alpha has been multiplied by 16x to make the noise more visible. I also zoomed in 2x.
(Open the images in a new tab and switch between them to see the differences.)
As we can see, the new method produces generally sharper results with a lot less haloing around edges.