Reputation: 73
Quick question about displaying an image with Python, difference between
im = Image.fromarray(noisyImage)
im.show(noisyImage)
I get this:
http://s30.postimg.org/xbkxly81t/other.png
Then when i use matplotlib i get this:
plt.imshow(noisyImage)
plt.show()
http://s30.postimg.org/64odx64ap/mtlibplt.png
please could someone explain why, when its the same image, just different method of display? really confused!! where does the colour even come from on the matplotlib?
Also whats all the noise at the top of the first image? if i do not attempt to change the image it is fine. thanks
thanks for any help.
Upvotes: 1
Views: 163
Reputation: 879271
PIL's show
is a convenience function which uses os.system
to call some OS-dependent image viewer on your machine.
You can find out what command is being used to show the image by doing this:
In [37]: import ImageShow
In [38]: [viewer.get_command_ex('file')[0] for viewer in ImageShow._viewers]
Out[38]: ['display']
So on my Unix machine, PIL's show
is using imagemagick's display
program.
Matplotlib's plt.show
function uses a GUI backend such as tk
, gtk
, pyqt
or wxpython
to draw the plot.
Upvotes: 1