Painted_area = sum(img_array.flatten()) / test_render_size ** 2. #only proceed if painted area meets threshold, otherwise loop to top #only proceed if test attractor did not fail Img_array, xy_pos = test_render(x_coefficients, y_coefficients, # Set the tweakable values of the attractor equations: Greyscale=True, alpha=False, bitdepth=16) ImgWriter = png.Writer(final_render_size, final_render_size,
01 # reject attractor if less than this portion # falls further than this distance from origin Trap_range = 2 # potential attractor is rejected if xy_pos # optimised rendering loop with no error checking etc. # do this resulting in "wrap-around" imagesĭef final_render(x_coefficients, y_coefficients, Return np.array(im2, int).reshape(im.shape), cdfĭef test_render(x_coefficients, y_coefficients,
I have tidied up the code and made several optimizations for speed: Also GIMP is currently geared towards 8-bit images, so no good in this case.Īnd for the sake of completeness, here is the latest version of my strange attractor finder. GIMP and CinePaint also have an equalize feature, but no option that I could find to base the histogram on a selected portion of the image. In Linux you can do the same thing with ImageJ, including selecting a region to base the histogram on.
This can be very useful for negating a black background, or a white sky etc. If you select an area of the image first the equalization for the entire image can be based on the histogram of just the selected portion. I believe it is found under Levels > Adjustments > Equalize. If you’d rather used an image manipulation program to do this, the effect is available in Photoshop.
Return np.array(im2, int).reshape(im.shape) #use linear interpolation of cdf to find new pixel values Imhist,bins = np.histogram(im.flatten(),nbr_bins,normed=True)Ĭdf = imhist.cumsum() #cumulative distribution functionĬdf = (2**16-1) * cdf / cdf #normalize I also set the first bin of the histogram to zero – this is to negate the large amount of black background which would otherwise ruin the equalization effect.ote I just had to make some small alterations so it would work with 16 bit images. Luckily I found a suitable algorithm on Salem’s Vision Blog.
Note that the grainy texture is due to the number of samples taken and not from the equalization process.Īs I wanted to be able to quickly assess a folder full of thumbnails for interesting imaged, it made sense to find a way to programmatically equalize the images in Python before they are first saved to disk. Effectively the surplus of dark shades in my images can be spread up towards the right of the value histogram.Īs you can see in these examples of the same image first normalised, and then equalized, equalization really brings these images to life. Peaks in the histogram are widened and the troughs condensed. This technique actually redistributes the value densities along the histogram so that each value range is more evenly represented.