Jump to content

Super Sampling?


Go to solution Solved by Rick Brewster,

Recommended Posts

Is there any chance of Super Sampling coming back?

 

It's removed in 5.0 because Adaptive is supposedly better quality.

 

Unfortunately, Adaptive creates a lot of artifacts near the edge of a transparent image when resizing, pixels that look transparent, but are just slightly off 100% transparent.

 

This makes it much harder to work with magic wands from there on, as it doesn't select the almost but not quite transparent pixels when using 0% toleracy.

 

It also causes problems when importing these images into programs that rely on 100% transparency. For example, if importing an image that has been enlarged in Adaptive mode into Tabletop Simulator, you'll get selection outlines around the almost but not quite transparent pixels, because they aren't exactly transparent.

 

Super Sampling was by far the best Algorhythm for the edges of images with transparent backgrounds. I often used other methods to increase the image size, but then used Super Sampling to increase the older image by the same size, and applied its alpha mask because the edges were superior.

 

I still have an older version running on an older PC, and I currently see myself forced to do any resizing on the older PC, because none of the current options come close to how Super Sampling did it.

 

See the example below. The left image is the original image. The right image has been increased to 200% using Adaptive. Then I used the magic wand at 0% tolerancy. The outline of the left image is smooth, while the outline of the right image has these almost transparent artifacts around it.

 

adaptive-example.png

  • Upvote 2
Link to comment
Share on other sites

46 minutes ago, Thels said:

I still have an older version running on an older PC, and I currently see myself forced to do any resizing on the older PC, because none of the current options come close to how Super Sampling did it.


For reference, could you post a copy of your original image and the 200% resized image, as you did above, but using the older version of paint.net and Super Sampling please.

Link to comment
Share on other sites

Super Sampling won't be coming back; I actually found some pretty nasty bugs in it that I was unable to find solutions for. The code was written a long time ago, had a lot of crazy optimizations in it, and it was simply unsalvageable.

 

However, Super Sampling was only ever active when reducing the size of an image. When enlarging, bicubic was used (when SS was selected). So what you were seeing was not super sampling anyway.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

@Thels On the left is the nearest I could find to your bowling ball on a transparent background.

On the right is the same image resized by 200% with Bicubic resampling and then the transparent area selected using the Magic Wand with 50% tolerance.

 

Super-sampling.png



It looks OK to me.

You get a similar result if you use Adaptive resampling.
 

  

On 3/29/2023 at 10:07 AM, Thels said:

Adaptive creates a lot of artifacts near the edge of a transparent image when resizing, pixels that look transparent, but are just slightly off 100% transparent.
 

This makes it much harder to work with magic wands from there on, as it doesn't select the almost but not quite transparent pixels when using 0% toleracy.


If you really want to use 0% tolerance Magic Wand selection in the remainder of your editing, then clean up the near transparent fuzz around the resized ball by Magic Wand selecting with 50% tolerance (or whatever % works for you) then pressing Delete. Now you will have fully transparent pixels right up to the edge of the ball.


 

 

Link to comment
Share on other sites

On 3/29/2023 at 5:39 PM, Rick Brewster said:

However, Super Sampling was only ever active when reducing the size of an image. When enlarging, bicubic was used (when SS was selected). So what you were seeing was not super sampling anyway.

Are you sure on that? I went onto the PC with the old Paint.net and compared. The edges of Super Sampling are definitely different from the edges of Bicubic. If you look at the attachment, the Super Sampling image is 264x264, whereas the Bicubic image is 262x262. Zooming in, the edges definitely look different.

 

Also, the result of Bicubic changed. On the old Paint.net, I don't get any artifacts around the edges. On the new Paint.net, I do get artifacts. Not nearly as much as Adaptive, but they're there. Lanczos also has heavy artifacting going on (it looks similar to Adaptive). Only Bilinear, Fant and Nearest Neighbor do not. Bilinear is the one that resembles the old Super Sampling results for edges the closest, but it doesn't come as close in quality.

Compare-Resizes.png

It's a shame if Super Sampling goes the way of the Dodo. It had by far the best quality for the edges of transparent images. I tended to use AI upscaling tools to increase image sizes, but they were generally rather poor with the edges of transparent images, so I used Super Sampling for the Alpha.

 

Is there any chance another option will become available that focuses on the quality of the edges of transparent images, like Super Sampling did?

 

Here's a version with the 100% transparent areas converted to pink, so you can easily see the artifacts without first downloading and opening the image:Compare-Resizes-Pink.png

 

On 3/29/2023 at 6:24 PM, Tactilis said:

If you really want to use 0% tolerance Magic Wand selection in the remainder of your editing, then clean up the near transparent fuzz around the resized ball by Magic Wand selecting with 50% tolerance (or whatever % works for you) then pressing Delete. Now you will have fully transparent pixels right up to the edge of the ball.

I should not be needing to remove semi-transparent parts of the image to deal with the artificing. Especially not when it used to be not needed at all.

Edited by Thels
Link to comment
Share on other sites

20 minutes ago, Thels said:

Are you sure on that?

100% yes. Although, looking at the old code, it looks like a different implementation of bicubic was used, so I guess that's not as accurate as I thought. "Bicubic" would use WIC's Bicubic, whereas Super Sampling when enlarging would use my own implementation of Bicubic. Not sure why that is. The new "Bicubic"  in 5.0 is using @saucecontrol's MagicScaler library (also for Bilinear (not the low quality version), Bicubic, Adaptive, and Lanczos).

 

This might just be a bug in MagicScaler ... cc @saucecontrol ? It looks like the alpha channel is not correct here. We're getting alpha values that go e.g. 0, 0, 1, 2, 0, 0, 17 (when Color Picker-ing left-to-right) instead of a monotonic ramp from 0 to larger values.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

BTW some simpler repro steps:

 

1. Create a 128x128 pixel image, then draw an antialiased filled circle. Here's the image I'm using:

image.png

 

2. Go to Image -> Resize, select "Adaptive (Best Quality)", then "By percentage: 200%"

image.png

3. Switch to the Magic Wand tool, set Tolerance to 0%, and the Flood Mode to Global

image.png

4. Click in the transparent region

 

5. You'll see a selection that has an "inner moat" of transparent pixels. So the image goes from transparent, to non-transparent, back to transparent (this is the bad part), and then properly to non-transparent:

image.png

 

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

  • Solution

Okay from talking with @saucecontrol, he was able to clear up some of the details.

 

1. Adaptive "Best Quality" should probably not have "Best Quality" in the name. This does have a sharpening effect, by design. Same goes for Bicubic and Lanczos.

 

2. Bilinear will produce good results without the "transparent moat" (which is a ringing artifact from the sharpening).

 

3. The old "Super Sampling" mode, for enlarging, which was actually using my own implementation of bicubic for enlarging (I'll call it "PdnBicubic"), can be reproduced using Magic Scaler. There are a few per-pixel discrepancies but they are just a +/- 1 in the RGB values due to differences in precision or rounding (MagicScaler is probably producing the more ideal result).

 

So I think what I'm going to do, for the next update (5.0.4) is this:

 

1. Rename "Adaptive (Best Quality)" to "Adaptive". @saucecontrol apparently objected to the "Best Quality" label but I missed it or forgot

 

2. Rename "Bicubic" to "Bicubic (Sharp)"

 

3. Add "Bicubic (Smooth)" which will almost identical to the old "Super Sampling" when enlarging.

 

This means you would just use "Bicubic (Smooth)" to get what you need/want in this case. I could probably put up a test build shortly, this isn't difficult from a coding standpoint.

  • Like 2
  • Upvote 4

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

I know OP was upscaling, but I am downscaling and have always used supersampling. I wanted to write some notes here for fans of the old supersampling (but the context is only downscaling).

 

I discovered that an up-to-date "fant" (from 5.0.7) was doing what I always thought supersampling was doing for downscaling (the box filter). In fact, I can't find any difference except for rounding errors (that is, +/- 1). These errors had an artificial line-like structure; I assume these came from the old "unsalvageable" optimizations. In the 4.2.14 paint.net I've been using for years, fant looks pretty decent on casual inspection but seems offset by half-pixels down and right perhaps. Most importantly, the 5.0.7 fant doesn't have this problem.

 

Therefore, for fans of supersampling for downscaling, I suggest you use fant but check your paint.net version closely to make sure it is the latest version or one that has the superior fant. I'm okay with supersampling being removed because now this fant's close enough for my needs. You just have to know to use it when you discover supersampling is missing (and that education is what this post is for.)

 

I don't recommend bicubic (smooth) for fans of supersampling downsampling. You're not going to like it. It gets rid of the ringing, but at what cost!?

 

For fans of supersampling for downscaling, I think you must also disable the gamma correction. While the gamma correction yields some interesting results (I had one test case where it saved some stars in a starfield that would have otherwise disappeared) it also invariably gives an impression of changing the image overall when a/b tested with the original. I don't think fans of supersampling for downscaling will like that.

 

 

  • Like 1
Link to comment
Share on other sites

@zeromus, your observations are spot on. 

 

To fill in some more details on the deal with Super Sampling vs Fant:

 

The pre-5.0 versions of Paint.NET used WIC's implementation of Fant (and it is indeed offset by 1/2 pixel in some cases, like upscaling). It mostly works but has some bugs of its own. The Super Sampling implementation was one that I wrote and it dates back to ... I'm not even sure, but it was really old. At least 15 years.

 

The current version of Paint.NET (5.0.7) uses my own implementation of Fant. It is not optimized for performance; instead, I wrote the code so that it would be correct and maintainable ("legible" would be another term, "easy to inspect for correctness", etc.). It is a correct implementation of an algorithm that is equivalent to Fant and is essentially as you describe: the old Super Sampling minus the bugs. When I wrote the original code for Super Sampling, I did not realize at the time that I was implementing an algorithm that was equivalent to Fant.

 

You could even say that pre-5.0, "Fant" and "Super Sampling" should have been equivalent for downscaling. They were not, however, due to mismatched bugs in their implementation. In 5.0.7, if you want "Super Sampling", just use Fant. It is exactly what you want. For upscaling, Fant is equivalent to Bilinear (Low Quality), and the old Super Sampling would revert to an algorithm equivalent to Bicubic (Smooth).

 

As for gamma correction, that should be enabled or disabled based on the nature of the image's contents and your personal preference. A correct implementation of Fant, without gamma correction, often produces results that are similar in brightness to using one of the other sampling algorithms with gamma correction. It's still not "correct," but it does look similar to the human eye (and subjective results are very important in this space). There is no ringing like with most of the bicubic modes (other than Bicubic Smooth, which has no ringing), but it does have aliasing artifacts. Those artifacts incorrectly boost the brightness, but the errors actually cause a pseudo gamma correction effect.

 

Bicubic (Smooth), btw, is provided primarily for upscaling. Its major feature is that it does not have any ringing/sharpening artifacts.

  • Like 2

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...