Jump to content

How does "Quality" work?


Xhin

Recommended Posts

Gaussian Blur? No.

For the built-in effects, at least, quality affects how many samples are calculated for each output pixel. It's a non-linear relationship though between the quality value and # of samples. The samples are then blended together. It's just like your typical GeForce's MSAA (multi-sample anti-aliasing).

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

Oh, and further explanation. Multisampling works for those effects because they are essentially mathematical functions defined on the set of real numbers (not just at integer pixel coordinates). Multisampling works by taking >1 sample of that mathematical function at various locations within each pixel (e.g. [x+0.25,y+0.75], [x+0.75, y+0.25], etc). Then those samples are averaged (blended) to calculate the final output value.

  • Upvote 1

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

Is there a way of tapping into that native multisampling algorithm, or would I have to calculate it manually if I wanted to build a plugin with a quality control?

I might be going about this the wrong way though, what I'm looking to do is to rotate part of an image an arbitrary number of degrees without messing up its quality. I figured something like whatever the quality slider or anti-aliasing tool did would work to fix jagged edges and whatnot.

I appreciate your help. Also, just curious, why are the quality sliders limited to 5? What does the quality number actually mean?

xhin.png

Link to comment
Share on other sites

A 'quality' slider is just a control which returns a value. You have to define what the return value is used for.

As Rick said, in most cases it just tells that the algorithm will do a more precise calculation of the final pixels.

But this means if you like to get more quality then it takes a lot more time to do the calculation (sometimes minutes or hours).

midoras signature.gif

Link to comment
Share on other sites

  • 4 weeks later...

if you need some simple smoothness effect you can simple pick the color of the surrounding pixels of each pixel and use the average as your pixel color .

this actually simulates Paint.NET's built-in Median effect , and it gives a nice smooth for your effects .

this might be coded like so:

	    ColorBgra CurrentPixel,pxl1,pxl2,pxl3,pxl4,pxl5,pxl6,pxl7,pxl8;
	    CurrentPixel = src[x,y];
	    pxl1= src[Math.Min(x+1,rect.Right-1),y];
	    pxl2= src[Math.Max(x-1,rect.Left),y];
	    pxl3= src[x,Math.Min(y+1,rect.Bottom-1)];
	    pxl4= src[x,Math.Max(y-1,rect.Top)];
	    pxl5= src[Math.Min(x+1,rect.Right-1),Math.Min(y+1,rect.Bottom-1)];
	    pxl6= src[Math.Min(x+1,rect.Right-1),Math.Max(y-1,rect.Top)];
	    pxl7= src[Math.Max(x-1,rect.Left),Math.Min(y+1,rect.Bottom-1)];
	    pxl8= src[Math.Max(x-1,rect.Left),Math.Max(y-1,rect.Top)];
	    CurrentPixel.R=(byte)((CurrentPixel.R+pxl1.R+pxl2.R+pxl3.R+pxl4.R+pxl5.R+pxl6.R+pxl7.R+pxl8.R)/9);
	    CurrentPixel.G=(byte)((CurrentPixel.G+pxl1.G+pxl2.G+pxl3.G+pxl4.G+pxl5.G+pxl6.G+pxl7.G+pxl8.G)/9);
	    CurrentPixel.B=(byte)((CurrentPixel.B+pxl1.B+pxl2.B+pxl3.B+pxl4.B+pxl5.B+pxl6.B+pxl7.B+pxl8.B)/9);

Hope you find this helpful :D .

Ahmed.

Link to comment
Share on other sites

if you need some simple smoothness effect you can simple pick the color of the surrounding pixels of each pixel and use the average as your pixel color .

this actually simulates Paint.NET's built-in Median effect , and it gives a nice smooth for your effects .

Unfortunately that has absolutely nothing in common with the multisampling algorithm which is configured via the "Quality" slider. (Fortunately that doesn't imply your idea is worthless or anything, that's not what I mean)

What you describe is essentially a smoothing effect accomplished with post-processing, which reminds me a bit of FXAA or Quincunx. Multisampling works by gathering samples within the same pixel. Without it you get all the shimmering artifacts typically associated with Nearest Neighbor resampling when you shrink an image (and, in fact, they are the exact same thing).

  • Upvote 1

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

Unfortunately that has absolutely nothing in common with the multisampling algorithm which is configured via the "Quality" slider. (Fortunately that doesn't imply your idea is worthless or anything, that's not what I mean) What you describe is essentially a smoothing effect accomplished with post-processing, which reminds me a bit of FXAA or Quincunx. Multisampling works by gathering samples within the same pixel. Without it you get all the shimmering artifacts typically associated with Nearest Neighbor resampling when you shrink an image (and, in fact, they are the exact same thing).

wait , you meant smoothing works on each pixel ?

can you link me to a wikipedia topic, please ?

Link to comment
Share on other sites

Smoothing and multisampling aren't the same. Just look it up... you know, type in "multisampling" into a search engine and then hit enter :)

Which one can be used depends on the fundamental algorithm of your effect.

  • Upvote 1

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

  • 8 months later...

Hi Rick,

 

Thanks for the detailed info. If you are using MSAA, can you please tell me if your implementation is regular grid, sparse regular grid or stochastic sample patterns? Also when you said "within the same pixel", I am not sure what you mean because by adding offsets less than 1 to the original integer pixel coordinate, are you not crossing into the other pixels? Or do you mean it's within 1 pixel range so it's not like smoothing algorithms which use a larger radius and therefore the average gets more blurry?

 

Also another thing that confuse me is, is it not better to use all float coordinates [0..1] instead of integer pixel coordinates which makes adding of floating point offsets more complex?

 

Thanks again.

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...