Welcome to Fractal Forums

Fractal Software => Sterlingware => Topic started by: chaos_crystal on December 13, 2012, 01:25:08 AM




Title: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: chaos_crystal on December 13, 2012, 01:25:08 AM
Hi all,  ;D  it's been a long time since I posted here! I still use mainly 2D fractal programs such as Fractal Explorer, Sterling2, and Tiera-Zon. Haven't poked around with Mandelbulb 3D much, partly b/c of a stubborn computer that seems to be getting cranky in its "advancing" age (probably 6+ years I'm guessing, it was refurbished and reformatted in 2009 and I received it as a gift, so who knows) and takes years to render anything bigger than a fairly-large size 2D fractal scene.

Anyway, in learning a bit more about Sterling2, I read about how to antialias...that is, make the image 4x larger than the final version, hit 4:1 and supposedly, you have a buttery smooth perfect rendering....after waiting about half an hour...LOL. I find that if I have an image that has a ton of impossibly intricate detail and try this, I wind up with the fine details looking blurry, even though bigger simpler sections of the image might look great.

I have produced a good many fractals that sport jagged edges....even if they are looking spiffy otherwise. And I really do not mind seeing those color bands that could be blended by antialiasing... I just wish I knew the best way to get rid of the jaggies w/o losing the tiny details. There is a limit, apparently, but where to draw the line, so to speak? I am puzzled and a bit frustrated.  :-\

Here is a link to a site where a guy is thoroughly against antialiasing, it seems:

http://www.1up.com/do/blogEntry?publicUserId=6143216&bId=9098879 (http://www.1up.com/do/blogEntry?publicUserId=6143216&bId=9098879)

And yes, you can even see a good few of my latest efforts right here, at my website link...commentary and critiques are welcome!  - thanks :

http://wildwanderingirl.wordpress.com/ (http://wildwanderingirl.wordpress.com/)


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Tglad on December 13, 2012, 03:21:04 AM
The guy in your link who is against anti-aliasing has defined it as blending with neighbouring pixels in the image. So he is actually criticising blurring, not anti-aliasing.
What you're doing is supersampling (which is a common method of antialiasing), and it actually adds detail to the image rather than taking it away. If you only have a certain number of pixels to work with then a more densely sampled average of the colour under each square pixel will always be more accurate.

There is an exception to this rule... if you are rendering details which have no area by definition, e.g. lines, points, fractals like Koch curve, menger carpet, Sierpinski triangle etc then the problem is that more supersampling just dilutes the pixels until you can't see the shape at all!
The best result would be to darken each pixel in proportion to the length of the line under the pixel in the case of lines, or the number of points under the pixel in the case of points.
In practice this can be done by counting the supersampled pixels under one pixel that contain the geometry and multiplying that figure by the supersample size to the power D. When we're rendering points D = 0, when we're rendering lines D = 1. This then generalises to other fractals by setting D to the fractal dimension of the fractal.

I have never seen anyone (including myself) ever actually try this form of antialiasing... but it should be the best way to show the details. Maybe you could be the first to try it!


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: chaos_crystal on December 13, 2012, 04:46:24 AM
What you're doing is supersampling (which is a common method of antialiasing), and despite what you think it actually adds detail to the image rather than taking it away.

I remember hearing about 'supersampling' during my experiences with the program XnView. I kinda stopped using that (although it would be easy to get back) when someone told me simply saving my BMP files as PNG files would be a good solution to aiding picture quality. It certainly has helped with color quality, although, as mentioned, I am concerned about the jaggies.

Quote
There is an exception to this rule... if you are rendering details which have no area by definition, e.g. lines, points, fractals like Koch curve, menger carpet, Sierpinski triangle etc then the problem is that more supersampling just dilutes the pixels until you can't see the shape at all!

Right! You've seen fractals that have areas that look like tangled masses of steel wool or something? Sterlingware tends to turn out these complicated fractals. Of course zooming in brings out the nice details, but those tangled areas are still present on the scene and going into infinity. If you have a good image that contains those things, that is the part that gets blurry and, well, ugly.

Quote
The best result would be to darken each pixel in proportion to the length of the line under the pixel in the case of lines, or the number of points under the pixel in the case of points. In practice this can be done by counting the supersampled pixels under one pixel that contain the geometry and multiplying that figure by the supersample size to the power D. When we're rendering points D = 0, when we're rendering lines D = 1. This then generalises to other fractals by setting D to the fractal dimension of the fractal.

I have never seen anyone (including myself) ever actually try this form of antialiasing... but it should be the best way to show the details. Maybe you could be the first to try it!

I would be happy to give it a go....(always ready to try new things and be a trailblazer, as befits Aries!) if I knew enough about math to know how to go about it?

Here is a scientific PDF document that might explain this, to someone a lot smarter than me!

http://www.x86-secret.com/articles/divers/v5-6000/datasheets/FSAA.pdf (http://www.x86-secret.com/articles/divers/v5-6000/datasheets/FSAA.pdf)


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Tglad on December 15, 2012, 02:08:20 AM
I built the algorithm and it works really well:
(http://4.bp.blogspot.com/-4VYRYszxyLs/UMvE10jYylI/AAAAAAAAAOA/tSfIqfG0TDw/s1600/supersample2.png)
The left image is black if any of the supersampled points is inside the Mandelbrot set- too jagged, no anti-aliasing
The right image averages the supersampled points- smooth but the lines at the top fade away, you can't even see the top area
The middle is the method I described- smooth on the smooth areas and you still see the full structure

I put it in a blog post- http://tglad.blogspot.com.au/2012/12/dimension-aware-rasterising.html (http://tglad.blogspot.com.au/2012/12/dimension-aware-rasterising.html)


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: kram1032 on December 15, 2012, 05:11:17 PM
Very interesting idea.
I wonder if it could be refined. Boxcounting might give directional bias, right? If you somehow could use circle-counting...
Though that would be much slower, I guess.


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Syntopia on December 16, 2012, 12:24:35 AM
Another way to bring out detail when rendering 2D fractals, is to use a distance estimator. For near-dust fractals this makes is possible to get quite good quality, where standard sampling would fail.

Here is an example with DE-rendering, which is difficult render for high iteration counts using standard sampling:
(http://www.hvidtfeldts.net/blog/media/Mandelbrot-DE.png)


Parameters:
Iterations = 2000
Breakout radius = 10
JuliaX = -0.77896
JuliaY = 0.12536

Could you try your method for these settings?


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Tglad on December 16, 2012, 08:19:14 AM
Nice image... how do you use the distance estimator... do you only do one sample per pixel? and what is your zoom level?

I think that DE is basically an approximation of supersampling, because it uses the distance to approximate how much of the surface under the pixel is inside the set.
For an image which is roughly the same fractal dimension everywhere (I think your image is an example of this) there wouldn't be a difference between current rendering methods and darkening using this new method. One would just be a multiple of the other.

The method is useful when there are parts of different dimensions in the same image, such as this one:
The first three rasterisers are appropriate for points, lines and surfaces respectively, and each work well for that geometry. The fourth is my method, it calculates the fractal dimension per pixel and renders appropriately. So you get anti-aliased lines and anti-aliased disk in the same pic.


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Syntopia on December 16, 2012, 08:26:17 PM
I dont think DE-methods are similar to supersampling - for very light / zero area systems (like the one above), you are not likely to hit anything in the set by just doing point-sampling. But with a DE, you can add some width to the set. For instance, here is the system again, drawn with 16 samples per pixel, and colored if just one sample hits the set:

(http://www.hvidtfeldts.net/blog/media/Mandelbrot-No-DE.png)

The above image was rendered with 700 iterations. With 2000 iterations it nearly disappears completely.


I find the distance like any ordinary 3D DE:
Code:
	vec2 dz = vec2(1,0);
for (i = 0; i < Iterations; i++) {
dz = complexMul(z,dz)*2.0 + (Julia ? vec2(0.0) : vec2(1.0,0.0));
z = complexMul(z,z) + (Julia ? c2 : c);
if (dot(z,z)>100) break;
}

float r = length(z);
float de = r*log2(r)/length(dz);

And then consider a point to be part of the set, if closer than a treshold (that determines how dense the drawing will be - notice this is dependent on zoom factor). In the image in the previous post, I used 16 samples (chosen spherically around the pixel center, and weighted with a gaussian function).


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Tglad on December 17, 2012, 09:00:03 AM
Yes point-sampling is bad, you want to 'pixel sample' i.e. see if the whole pixel contains the set. In my previous picture I was 'pixel sampling' rather than point sampling, otherwise the lines and points wouldn't have shown up at all.
DE is basically sampling a disk rather than a point, and the threshold specifies the disk radius.

So normal threshold would be half the supersample pixel size right? But if you make it half the actual pixel size then you get something similar to my method, since it will render thin lines and points anti-aliased without them fading out. Here's a comparison, the left uses my method and right is with half a pixel width added. You get fatter lines and the points are more blurred with the right image. Not a big difference, I'll compare a mandelbrot next.




Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Tglad on December 17, 2012, 12:42:34 PM
Here's a high res mandelbrot comparison with 16x16 supersampling.
The left uses DE threshold of 0.5*supersample pixel width, i.e. proper 16x16 supersampling. The tree parts fade out.
The middle is the method I described.
The right is using a DE threshold of 0.5*the pixel size, to get full darkness on even 1d lines. You can see it is a bit chunky so loses details.
(you have to download the image and zoom in to see the antialiasing)


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: kram1032 on December 17, 2012, 01:28:14 PM
TGlad, can you retry your experiment with the parameters Syntopia gave before?


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Syntopia on December 17, 2012, 10:02:29 PM
Yes point-sampling is bad, you want to 'pixel sample' i.e. see if the whole pixel contains the set. In my previous picture I was 'pixel sampling' rather than point sampling, otherwise the lines and points wouldn't have shown up at all.

How does this pixel sampling work? I guess you can do square/line intersections when drawing e.g. lines, but don't you need something like a DE to check if a given square area contains a point in a fractal set?



Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Tglad on December 18, 2012, 12:27:34 AM
Yes sorry I am using DE for fractals. Checking whether the set is within a radius is close enough to checking whether the set is inside the pixel (or sub pixel). The difference is only in how you choose a shade given the number of supersample pixels that contain the set.
Kram I'll give it a go but not sure how deep the zoom is...


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: kram1032 on December 18, 2012, 11:44:35 AM
Well, it's approximately deep but not very deep. :D
Syntopia, could you clarify on that?


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Syntopia on December 18, 2012, 09:26:53 PM
Well, it's approximately deep but not very deep. :D
Syntopia, could you clarify on that?

The zoom? Not very far - one quarter size or so. The Fragmentarium params are:

Center = -0.0430245,0.319072
Zoom = 3.05902

I think Zoom = 1 would correspond to rendering (-1,-1) to (1,1) - at least if the viewport is square.


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Tglad on December 19, 2012, 10:58:36 AM
Here is Syntopia's Julia set example using normal supersampling at 2x2 on the left and 16x16 on the right
(http://3.bp.blogspot.com/-lKe8Ljc-KwM/UNGK5YR-LTI/AAAAAAAAAOg/-Dsv3vYRJFs/s1600/supersampleCompare.png)
lots of detail but fractal fades away as you get more accurate, as n increases in nxn supersampling.

Since my method calculates the shade by just scaling the number of supersample points by n^-dimension rather than n^-2, and since a Julia set has constant dimension, my method does nothing more than make the image darker on this fractal.
In this case that is a problem because you lose detail if you make it darker and clamp to values beyond black (left image below, 16x16), but you can always scale the darkness down as in the right image:
(http://3.bp.blogspot.com/-kl_LcQ2czog/UNGL4PvzQqI/AAAAAAAAAOs/pR0s9FsViuk/s1600/newmethodscaleddown.png)

I find the fractal dimension per pixel in the image using simple box counting, here is an image of the Mandelbrot coloured by the dimension at each pixel, for 20 iterations and 2000 iterations. The paler colour is lower dimension:
(http://2.bp.blogspot.com/-4ufiOpEjY28/UNGOjljnmwI/AAAAAAAAAPA/0vV-7Z5ogLA/s1600/dimension20vs2000iters.png)


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: lycium on December 19, 2012, 04:30:53 PM
You should bear in mind that displays don't have linear brightness response, i.e. you have to apply gamma correction after you've done your AA.


Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: Syntopia on December 19, 2012, 06:02:44 PM
This box-counting thing could be interesting to for making a automated journey through the Mandelbrot set. You probably want to zoom in on regions with a dimension somewhere between void and massive.

Btw, on problem with method is that it is not obvious how you handle supersamples of different color. (The same of course applies to my DE-based renderings).

You should bear in mind that displays don't have linear brightness response, i.e. you have to apply gamma correction after you've done your AA.

The Fragmentarium image was Gamma corrected, which actually helps a lot in bringing out detail (and will reduce anti-aliasing artifacts, such as roping on straight lines).

Btw, I used 16 samples per pixel in my image, not 16x16 (not that there is much gained by going much higher in this case).



Title: Re: To anti-alias, or not to anti-alias? Hit the button or leave it alone?
Post by: chaos_crystal on December 19, 2012, 08:01:11 PM
Hum...I'm pretty much lost, not being very knowledgeable about much of the terminology and techniques discussed here. I doubt that my computer could even manage the processes you speak of. It's slow, and old, only 1 processor and 2 GB RAM. Anyway, here (see link) is a fractal image I've had for a while, not knowing for certain just what to do with it. I did try rendering it at 4 x original size and then antialiasing 3:1 (the tentative approach). That didn't help much. I suspect this is one of those that would have to be supersampled at 10 to 20 times actual size and then downsampled. My computer would probably freeze and roll over and die,  :o  LOL.

This is the original file complete with the "ugly" bits I don't intend to use:

http://img69.imageshack.us/img69/629/alittlenightmusicdemo.png (http://img69.imageshack.us/img69/629/alittlenightmusicdemo.png)

Here is a zoomed in portion:

http://img571.imageshack.us/img571/5930/alittlenightmusic1.png (http://img571.imageshack.us/img571/5930/alittlenightmusic1.png)

and here is a portion showing my pathetic efforts at antialiasing  :sad1: which show the exact problem I mention in my original post of this thread...

http://img191.imageshack.us/img191/1931/alittlenightmusic1aa.png (http://img191.imageshack.us/img191/1931/alittlenightmusic1aa.png)

There are many, many small delicate lines running everywhere, I've never seen a fractal like this one before (no idea how I conjured it up either!) and never since... Tglad has already said, "if you are rendering details which have no area by definition, e.g. lines, points, fractals like Koch curve, menger carpet, Sierpinski triangle etc then the problem is that more supersampling just dilutes the pixels until you can't see the shape at all!" That could be what's happening here. But I am unsure just how to fix such problems. Freeware such as Fractal Explorer and Tierazon, etc. don't have the DE feature or other options that might help.