Logo by KRAFTWERK - 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: Visit us on facebook
 
*
Welcome, Guest. Please login or register. April 16, 2024, 08:57:58 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]   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: Newton Fractal Smoothing  (Read 6178 times)
Description: I get some funny results with exponential smoothing
0 Members and 1 Guest are viewing this topic.
fodinabor
Forums Newbie
*
Posts: 4


« on: April 23, 2015, 03:02:42 PM »

Hey Guys,

I'm writing myself a Newton Fractal Generator. The images all formerly looked like this:

But I actually would like it to look a bit smoother - so I've done some research and I ran over http://www.hiddendimension.com/FractalMath/Convergent_Fractals_Main.html and some threads here and no it looks nearly fine, except that there are some issues at the edges of the basins..


This is my generation loop (it's ran in a OpenCL Kernel):

Code:
   while (i < 6000 && fabs(z.r) < 10000 && !found){
f = computeFunction(z, params, paramc[0]);
d = computeFunction(z, paramsD, paramc[1]);

iterexp = iterexp + exp(-fabs(z.r) - 0.5 / (fabs(subComplex(zo, z).r)));

zo = z;

z = subComplex(z, divComplex(f, d));

i++;

for (int j = 0; j < paramc[0] - 1; j++){
if (compComplex(z, zeros[j], RESOLUTION)){
resType[x + xRes * y] = j;
result[x + xRes * y] = iterexp;
found = true;
break;
}
}

if (compComplex(z, zo, RESOLUTION/100)){
resType[x + xRes * y] = 12;
break;
}
}

The coloration:

Code:
const int xRes = res[0];
const int yRes = res[1];

for (int y = 0; y < fraktal->getHeight(); y++){
for (int x = 0; x < fraktal->getWidth(); x++){
int type, it;
double conDiv;
if (genCL && genCL->err == CL_SUCCESS){
conDiv = genCL->result[x + y * xRes];
type = genCL->typeRes[x + y * xRes];
it = genCL->iterations[x + y * xRes];
} else {
type = 3;
conDiv = runNewton(std::complex<double>((double)((x - (double)(xRes / 2)) / zoom[0]), (double)((y - (double)(yRes / 2)) / zoom[1])), type);
}

if (type < 15){
Color col;
col.setColorHexRGB(colors[type]);
col.setColorHSV(col.getHue(), col.getSaturation(), 1-conDiv);
fraktal->setPixel(x, y, col);
} else {
fraktal->setPixel(x, y, conDiv, conDiv, conDiv, 1);
}
}
}

The full source code: http://git.war-of-universe.com/fodinabor/newton-fraktale

I appreciate any help to actually smooth this ;-)  
Thanks,
- fodinabor
« Last Edit: April 23, 2015, 05:40:51 PM by fodinabor » Logged
claude
Fractal Bachius
*
Posts: 563



WWW
« Reply #1 on: April 23, 2015, 05:57:45 PM »

I'd not seen the method you linked before, I'll have to try it sometime.  I use the ones described here:
http://www.chiark.greenend.org.uk/~sgtatham/newton/
Quote
a good ad-hoc approximation is obtained simply by looking at the last iteration, in which the point first comes within the specified distance of a root. We look at the distance D0 from the previous point to the root and the distance D1 from the new point to the root, and we know that the threshold distance T is somewhere in between the two. I've found that simply looking at (log T-log D0)/(log D1-log D0), in other words whether the log of the threshold radius was near to the start or the end of the inward distance travelled by the point (on a logarithmic scale), produces a perfectly acceptable result
You either add or subtract that expression from the integer iteration count, can't remember which.

Here's my GLSL implementation:
http://code.mathr.co.uk/fractaloids/blob/HEAD:/webgl/fractaloids.html#l39

Some example videos using variations of that code:
http://mathr.co.uk/blog/2012-12-24_fractal_juggling.html

You might also be interested in distance estimation, here's a post about that too:
http://mathr.co.uk/blog/2013-06-22_distance_estimation_for_newton_fractals.html
Logged
fodinabor
Forums Newbie
*
Posts: 4


« Reply #2 on: April 23, 2015, 06:25:22 PM »

I translated: (log T-log D0)/(log D1-log D0) into (log(RESOLUTION) - log(fabs(subComplex(zo, zeros[j]).r))) / (log(fabs(subComplex(z, zeros[j]).r)) - log(fabs(subComplex(zo, zeros[j]).r)));

zo is the old z, and zeros[j] is the root the Newton Method is converging to, .r is the abs value (sqrt(t.re*t.re + t.im*t.im))

« Last Edit: April 23, 2015, 06:32:55 PM by fodinabor » Logged
claude
Fractal Bachius
*
Posts: 563



WWW
« Reply #3 on: April 23, 2015, 07:14:48 PM »

looks good - now you just need to add the iteration count and adjust the colouring range - something like
Code:
col.setColorHSV(col.getHue(), col.getSaturation(), 1- (it + conDiv)/maxIters);
Logged
fodinabor
Forums Newbie
*
Posts: 4


« Reply #4 on: April 23, 2015, 09:12:13 PM »

thanks!

The coloration now looks like this:
Code:
int maxIters = 0;
for (int y = 0; y < fraktal->getHeight(); y++){
for (int x = 0; x < fraktal->getWidth(); x++){
if (genCL->typeRes[x + y * xRes] < 14){
maxIters = MAX(maxIters, genCL->iterations[x + y * xRes]);
}
}
}

maxIters = maxIters / polynom->getNumCoefficients()+1;

for (int y = 0; y < fraktal->getHeight(); y++){
for (int x = 0; x < fraktal->getWidth(); x++){
int type, it;
double conDiv;
if (genCL && genCL->err == CL_SUCCESS){
conDiv = genCL->result[x + y * xRes];
type = genCL->typeRes[x + y * xRes];
it = genCL->iterations[x + y * xRes];
} else {
type = 3;
conDiv = runNewton(std::complex<double>((double)((x - (double)(xRes / 2)) / zoom[0]), (double)((y - (double)(yRes / 2)) / zoom[1])), type);
}

if (type < 15){
Color col;
col.setColorHexRGB(colors[type]);
conDiv = conDiv + (double)it;
if (conDiv > maxIters)
conDiv = maxIters;
if (conDiv < 0.3)
conDiv = 0.3;
col.setColorHSV(col.getHue(), col.getSaturation(), (1.0 - mapCL(conDiv, 0, maxIters, 0.0, 1.0)));
fraktal->setPixel(x, y, col);
} else {
fraktal->setPixel(x, y, 0, 0, 0, 1);
}
}
}

and the result is:
« Last Edit: April 23, 2015, 09:47:16 PM by fodinabor » Logged
fodinabor
Forums Newbie
*
Posts: 4


« Reply #5 on: April 23, 2015, 10:12:42 PM »

hmm... I'd still get the exponential smoothing thing get to work.. it looks a little bit nicer and you don't have to say what to use as maxIters (as it does not smooth anything when using the real max val...
Logged
Pauldelbrot
Fractal Senior
******
Posts: 2592



pderbyshire2
« Reply #6 on: April 24, 2015, 04:38:04 AM »

Convergent basins are probably best smooth-colored by first finding a point belonging to the attractor and the attractor's period p, then examining every pth step of the orbit of a point that goes to that attractor and:

  • If the attractor is superattracting (which occurs with the finite attractors in Newton's method), using the usual divergent smooth coloring applied to 1/z for z the points in the (every pth point) orbit.
  • If the attractor isn't superattracting, or whether it is or not varies from point to point (Mandelbrot views do this), then once the orbit is close enough to the attractor it will spiral in in a predictable way: zn + p - za = k(zn - za), where za is the attracting point this 1/p sub-orbit converges to, and k is a complex constant with |k| < 1. This means that one point in the orbit will land in a target annulus around za whose inner diameter is |k| times its outer diameter. The logarithm of the proportion of the way this point landed between the inner diameter and the outer one is the fraction to add to the integer number of iterations (divided by p) taken to hit the annulus. (Thus, if the 6th iteration lands in the annulus, and it just barely does so, landing just inside the outer rim, that's maybe a 6.9; if it lands near the inner rim it's barely above 6.0; if it lands just past the inner rim, the fifth iteration should have landed just inside the outer rim, and we actually have a 5.9. So it's smooth and continuous.)

I use the second method in many of my own images to produce smooth basin coloring for, for instance, Julia set interiors.
Logged

Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Help! Newton fractal smooth shading Programming Softology 4 1623 Last post January 31, 2011, 12:36:46 AM
by Softology
FE Kaliset w/exp.smoothing Images Showcase (Rate My Fractal) Kali 3 3043 Last post February 14, 2012, 06:00:10 AM
by zonepatcher
Direct colouring exponent smoothing? 2D (new) Theories & Research Alef 4 747 Last post February 20, 2012, 04:35:29 PM
by Alef
Newton fractal roots in 3D space or arbitary dimension Help & Support misterstarshine 0 324 Last post November 15, 2015, 01:59:11 PM
by misterstarshine
Matlab: Newton-Fractal Programming Spalding 7 6193 Last post September 09, 2016, 05:04:42 PM
by superheal

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.141 seconds with 24 queries. (Pretty URLs adds 0.006s, 2q)