Hi, I am trying to create an image from an array using PIL, numpy and a colourmap from matplotlib.
I got the colourmap by using ipython and the following code colourmap = [] for i in xrange(256): r,g,b,a = cm.jet(i) r = int(round((r * 255),0)) g = int(round((g * 255),0)) b = int(round((b* 255),0)) colourmap.append((r,g,b)) The following is used to plot an array: def array2image(array, scale="log", filename="tmp"): # create image of the correct size new_image = Image.new("RGB", array.shape) # scan through a matrix and use Image.putdata() to put it in. x_size, y_size = array.shape largest = array.max() a_list = array.ravel() new_list = [] for x in a_list: if x == 0: new_list.append((0,0,0)) else: value = (log(x)/log(largest))*255 value = int(round(value,0)) value = blues_colourmap[value] #print value new_list.append(value) new_image.putdata(new_list) new_image.save(filename+".bmp") The image that is outputted is certainly correct for the data, however it is just no where near as "pretty" as the image you get from using plt.imshow(am_array) I'd like to get something that looks the same. I don't think the problems are because of the colourmap but rather because of my log scaling. Could someone please explain how matplotlib scales the image to make it look so nice? Regards, Ciarán ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users