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]
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]
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)) |