Logo by Dinkydau - 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. March 29, 2024, 02:38:48 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: Problem with Normalized Iteration Count at High Zoom (Mandelbrot, Python)  (Read 447 times)
Description: Unable to figure out how to normalize the colour
0 Members and 1 Guest are viewing this topic.
mandelbro82
Forums Newbie
*
Posts: 2


« 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
Logged
mandelbro82
Forums Newbie
*
Posts: 2


« Reply #1 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))
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  


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