From: Rein van den Boomgaard (UvA) <rein@sc...> - 2004-07-07 20:45:49
What is the prefered way to read in images in numarray/matplotlib?
I know of PIL but it seems like a lot of overlap with numarray just to read an
image from file.
I really need to read only one type of file (say ppm) and then i can use
imagemagick to convert from and to that format.
From: John Hunter <jdhunter@ac...> - 2004-07-08 22:17:11
>>>>> "Rein" == Rein van den Boomgaard (UvA) <rein@...> writes:
Rein> What is the prefered way to read in images in
No good way, currently. I plan to add a PNG loader in the near
future. Would this suffice for you? What do you think are the core
set of image formats that matplotlib should support? ... the fewer the
Rein> I know of PIL but it seems like a lot of overlap with
Rein> numarray just to read an image from file.
True, but for the record, here is the recipe I use to do the PIL ->
from matplotlib.matlab import *
im = Image.open('../data/leo_ratner.jpg')
s = im.tostring() # convert PIL image -> string
# convert string -> numerix array of floats
rgb = fromstring(s, UInt8).astype(Float)/255.0
# resize to RGB array
rgb = resize(rgb, (im.size, im.size, 3))
axis('off') # don't display the image axis