Logo by kr0mat1k - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Follow us on Twitter
 
*
Welcome, Guest. Please login or register. April 25, 2024, 02:42:19 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Mandelbrot questions  (Read 8673 times)
0 Members and 1 Guest are viewing this topic.
willemdv
Forums Newbie
*
Posts: 5


« on: November 26, 2014, 11:10:20 AM »

Yesterday I decided to draw a Mandelbrot to learn javascipt / canvas, but I am running into some problems.

- My smoothing looks crappy. Is this because I am using RGB averaging or is it because the fractions are wrong or to simple?
- When I zoom in, the x and y steps between pixels run out of precision before I'm hitting the maximum iterations. Is there a way to scale up the formula and parameters, so I can continue zooming?
- The edges look really hectic. Any tips on that?
- If I am zoomed in and I know it will take a least 20 iterations for any pixel to escape is there a more compact formula to skip really iterating trough the first 20. (I know this is unlikely but had to ask smiley )

http://pythonkings.nl/ai/mb/
(click to zoom, full screen is slow, render size is decided on page-load)

Logged
willemdv
Forums Newbie
*
Posts: 5


« Reply #1 on: November 26, 2014, 12:44:01 PM »


example
Logged
claude
Fractal Bachius
*
Posts: 563



WWW
« Reply #2 on: November 26, 2014, 12:56:52 PM »

Yesterday I decided to draw a Mandelbrot to learn javascipt / canvas, but I am running into some problems.

- My smoothing looks crappy. Is this because I am using RGB averaging or is it because the fractions are wrong or to simple?

you can get smoother smooth colouring by increasing the escape radius - i tend to use 512 instead of 2

Quote
- When I zoom in, the x and y steps between pixels run out of precision before I'm hitting the maximum iterations. Is there a way to scale up the formula and parameters, so I can continue zooming?

You might be able to use double-double technique to increase precision, but that would only postpone the inevitable - alternatively find a js arbitrary-precision floating point library.

libqd here is for C++/Fortran-90 but you might translate the functions you need to javascript http://crd-legacy.lbl.gov/~dhbailey/mpdist/

Quote
- The edges look really hectic. Any tips on that?

super-sampling can make them look smoother, alternatively look into distance estimate rendering

Quote
- If I am zoomed in and I know it will take a least 20 iterations for any pixel to escape is there a more compact formula to skip really iterating trough the first 20. (I know this is unlikely but had to ask smiley )

with perturbation techniques something like this is achievable with series approximation - you iterate one reference point at high precision generating coefficients for a polynomial approximation to initialize all the pixels after some iterations - see superfractalthing (java), kalles fraktaler (written in C I think), mandelmachine (source not available?)
Logged
willemdv
Forums Newbie
*
Posts: 5


« Reply #3 on: November 26, 2014, 01:02:15 PM »

Thank you for your advice. The first was a quick fix and I will look into the rest. smiley
Logged
willemdv
Forums Newbie
*
Posts: 5


« Reply #4 on: November 26, 2014, 03:27:40 PM »

So what is keeping me from getting the detail like the pictures on wikipedia?


compared to


This doesnt seem to come from super-sampling, distance estimate, float precision or iteration count.

My function:
    var xx = 0.0;
    var yy = 0.0;
    var iter = 0;
    while (xx * xx + yy * yy <= 512.0 && iter < MAXIT) {
        var temp = xx * xx - yy * yy + x;
        yy = 2 * xx * yy + y;
        xx = temp;
        iter++;
    }
    
    if ( iter < MAXIT ) {
        zn = Math.sqrt(xx*xx + yy*yy );
        nu = Math.log( Math.log(zn) / Math.log(2) ) / Math.log(2);
        iter = iter + 1 - nu;
    }
    
    return iter;
Logged
willemdv
Forums Newbie
*
Posts: 5


« Reply #5 on: November 26, 2014, 03:56:14 PM »

If I slow the gradient with higher iterations I am getting more detail.
( it / sqrt(it)*3 )
But I guess there is a better way to do this.
« Last Edit: November 26, 2014, 03:58:16 PM by willemdv » Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #6 on: November 26, 2014, 04:10:13 PM »

slowing down the gradient is quite a method, for your case you now need to apply the supersampling per pixel, the chaotic nature of the fractals produce random like pixel coloring because the color can be quite different to the current one compared to the neighbour pixel, espceially in the higher density regions, if you apply super sampling this dimishes out and produces the fine structures you see in the other pic
Logged

---

divide and conquer - iterate and rule - chaos is No random!
youhn
Fractal Molossus
**
Posts: 696


Shapes only exists in our heads.


« Reply #7 on: November 26, 2014, 06:56:34 PM »

Don't worry. Your code is correct for supersampling, but the combination of Javascript+Browser makes the edges look hectic.

Just check www.mandelbrot-set.com as you can see the same problem.

If you could make an export to PNG with high resolution and then scale back, your code would give the same sharp details as the wikipedia image. Or since you wanted to learn some code, maybe do the supersampling yourself?
Logged
therror
Explorer
****
Posts: 42


« Reply #8 on: February 21, 2015, 05:09:58 AM »

Hello! I have similar (or the same) problem. I wrote the program to plot Mandelbrot set (in C language, escape time algorithm). I want to plot images like in Wikipedia  embarrass Other aim - make the program fast as possible.  Unfortunately, at the border of the set there are "trash" instead small beautiful details (as in the images from Wikipedia). Please, help me. How to modify the program?
My image, scaled to 640x512.
P.S. Excuse me for my terrible English.


* output.jpg (102.13 KB, 640x512 - viewed 250 times.)
« Last Edit: February 21, 2015, 05:12:14 AM by therror » Logged
quaz0r
Fractal Molossus
**
Posts: 652



« Reply #9 on: February 21, 2015, 08:01:56 AM »

did you supersample that image?  it doesnt really look like it.  theres no such thing as a free lunch.  if you want beautiful perfectly detailed images you will have to pay the appropriate price to get them.
Logged
therror
Explorer
****
Posts: 42


« Reply #10 on: February 21, 2015, 08:16:48 AM »

I will try to apply supersampling today. I think it is incompatible with my aim to get fast program...
Logged
quaz0r
Fractal Molossus
**
Posts: 652



« Reply #11 on: February 21, 2015, 08:51:05 AM »

another way to look at it is that once you start paying the extra fees of admission to get higher quality images, you will appreciate that much more any efficiency and optimization improvements you make  cheesy
Logged
claude
Fractal Bachius
*
Posts: 563



WWW
« Reply #12 on: February 21, 2015, 04:14:10 PM »

I will try to apply supersampling today. I think it is incompatible with my aim to get fast program...

maybe try adaptive supersampling - for flat regions where colour doesn't change much you don't need to supersample as much as dense regions where the colour changes rapidly

also consider interior checking (even if you don't want to use distance estimate colouring): http://mathr.co.uk/blog/2014-11-02_practical_interior_distance_rendering.html
Logged
youhn
Fractal Molossus
**
Posts: 696


Shapes only exists in our heads.


« Reply #13 on: February 21, 2015, 05:20:16 PM »

I will try to apply supersampling today. I think it is incompatible with my aim to get fast program...

You really need both quality and speed. Otherwise go for non-AA images no higher then 160x120px or something like that, fast as hell.

For speed, you need to optimize every little detail of every step of the calculation and data storage and retrieval. This is black magic to me, but I know who've been there before. K.I. Martin, Karl Runmo and Botond Kósa. They made the following highly optimized (with perturbation theory) mandelbrot programs:

http://www.superfractalthing.co.nf/
http://www.chillheimer.de/kallesfraktaler/
http://web.t-online.hu/kbotond/mandelmachine/

All 3 have lots of details discussed here on the forums.

It's hard work. Good luck.
Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #14 on: February 21, 2015, 06:19:49 PM »

smooth(er) colouring in SFTC is done something like this after approximation...

calculate iterations for mandelbrot...
Code:
    while ( modulus < 4.0 )
    {
        x2 = ((dx - dxi)*(dx + dxi)) + c;
        dxi = (dx+dx)*dxi + ci;
        dx = x2;
        count++;
        if (count >= iterlim) return 0;
        modulus = dx*dx+dxi*dxi;
    }
after the above iterations are done, straighten out warped bands...
Code:
    /// a couple of extra iterations helps
    /// decrease the size of the error term.
    for (int i=0; i<4; i++) {
        x2 = ((dx - dxi)*(dx + dxi)) + c;
        dxi = (dx+dx)*dxi + ci;
        dx = x2;
        count++;
    }
then before returning the count value...
Code:
    modulus = dx*dx + dxi*dxi;
    /// return renormalized iteration count
    // linear interpolation http://en.wikipedia.org/wiki/Linear_interpolation count = (count+1 - (log( log(modulus) / log(2) ) / log(2)));
    // smoother version #B^]
    count = (count - (log( log(modulus*modulus) / log(2) ) / log(2)))*colorSpread;
    return count;

equivalent colour structure (transitions cover the same distance) with less banding
for an image with a palette of 1024 colours and colorSpread = radius (4.0 in this case)
the palette size can be increased to 4096 and the colorSpread muliplied by the same factor, colorSpread = 16
this gives a very smooth transition and doesn't seem to have much impact on rendering speed


* 4vs16.png (50.34 KB, 512x192 - viewed 307 times.)
« Last Edit: February 21, 2015, 06:41:29 PM by 3dickulus, Reason: image » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Pages: [1] 2   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Hi. I'm Daniel. I have some questions Meet & Greet Daniel_P 4 1846 Last post January 01, 2010, 09:19:11 AM
by Nahee_Enterprises
Some Mandelbulber Questions Mandelbulber mephisto69 3 5339 Last post October 19, 2010, 02:59:05 PM
by jwm-art
Some questions Theory Cobbles 8 4108 Last post June 22, 2011, 05:51:07 PM
by Cobbles
iam new so i have some questions JWildfire Nacer 3 1072 Last post November 09, 2013, 07:23:48 PM
by Nacer
2 Mandelbrot Remix Questions Mandelbrot & Julia Set MateFizyChem 4 5938 Last post October 25, 2016, 11:11:04 PM
by MateFizyChem

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.197 seconds with 24 queries. (Pretty URLs adds 0.011s, 2q)