Welcome to Fractal Forums

Fractal Software => Help & Support => Topic started by: mandelbro82 on April 02, 2017, 07:54:20 PM




Title: Problem with Normalized Iteration Count at High Zoom (Mandelbrot, Python)
Post by: mandelbro82 on April 02, 2017, 07:54:20 PM
Hi everyone, been working on fractals for about 3 weeks now in Python, using matplotlib for color maps, numpy for arrays, and PIL to store the RBG values into an image.  I've run into a problem when my zoom level starts increasing.  I'm using this:

mu = i + 1 - math.log(math.log((abs(z))/math.log(horizon)) #where horizon could be 2^60 or 4 for the escape

what I do now is get an rgb map from matplotlib, and do this:

rgba = cmap(mu/maxIt) #takes a color gradient (lets say red to blue) and creates an array (e.g.   1, 0.5, 0.5)

Next I multiply by 255 to convert to RGB, then load my image:
img[y]
  • = (int(rgba[0]*255), int(rgba[1]*255), int(rgba[2]*255))[/b]

    The above produces very nice and smooth color gradients at low levels of zoom and iteration counts.  The problem is I'm in the territory of high zooms (500,000) and iteration counts (55,000), where mu/maxIt that decides where the color gradient is, ends up being extremely low numbers (0.004=min, to 0.036=max), so of course if its a red gradient the detail is extremely minimal because it's only close to 0.  I tried normalizing the points like this:

    maxMU = np.amax(img) #these set the highest and lowest number of mu/maxIterations
    minMU = 0

    for y in range(imgy):  #this loops through each cell and normalizes the data so it's been 0 and 1.  the non escaped points (part of the M set) stay at 0 also. 
        for x in range(imgx):
            img[y]
  • = (img[y]
  • - minMU) / (maxMU - minMU)

for y in range(imgy):  #this loops through each cell and assigns an RGB tuple becaused on the point in the color gradient. 
    for x in range(imgx):
        rgba = cmap(img[y]
  • )
        newimg[y]
  • = (int(rgba[0]*255), int(rgba[1]*255), int(rgba[2]*255))

this method has not worked as it is producing some very weird looking images, looks like squares of pixels of different colors.  I'm not sure if it's just some sort of calculation error, but in theory it should work but the image looks like a table cloth of different colors lol. 

If anyone wants the code privately and wants to help, send me a message! 

these are the images I'm producing, the first one is my normal program, the others are when I try and normalize the colors from (0,1):

http://imgur.com/a/4TDBY


Title: Re: Problem with Normalized Iteration Count at High Zoom (Mandelbrot, Python)
Post by: mandelbro82 on April 02, 2017, 07:57:00 PM
looks like the code messed up sorry:

maxMU = np.amax(img)
minMU = 0

for y in range(imgy):
    for x in range(imgx):
        img[y][x.] = (img[y][x.] - minMU) / (maxMU - minMU)

for y in range(imgy):
    for x in range(imgx):
        print (cmap(img[y][x.]))
        rgba = cmap(img[y][x.])
        newimg[y][x.] = (int(rgba[0]*255), int(rgba[1]*255), int(rgba[2]*255))