[SciPy-User] fromimage/imread segfaults on my images
Christopher Barker
Chris.Barker at noaa.gov
Wed Mar 10 00:06:28 EST 2010
Daniel Lenski wrote:
> Everything works fine as long as I stick with PIL calls only... I can
> even dump the entire contents of the image to a string with
> PIL.Image.fromstring(). No problems there.
did you try passing that to numpy.fromstring? And what did it dump?
single images can be tricky.
>> np.asarray(pil_image)
>
> I looked at the code for scipy.misc.fromimage, and this is basically all
> it does. This is where the segfault occurs.
I don't think that code path has been highly tested -- and maybe never
for 1-bit images -- it eventually will be deprecated in favor of the new
buffer protocol anyway.
>> do you have a smaller image in the same format you can experiment with?
>> That might make it easier to figure out.
>
> Smaller images work fine. I haven't figured out exactly where the cutoff
> is, but 500x500 works fine, for instance.
I'd be surprised if size is the issue here -- your images just aren't
that big (as you pointed out, the MPL functions worked even though they
were converting to RGB). I'm just guessing that you problem had
something to do with the bits->bytes conversion.
>> http://netpbm.sourceforge.net/doc/pbm.html
>>
>> read the header, then read the data with np.fromfile(), then convert to
>> a uint8 array with np.unpackbits().
>
> That's what I've ended up doing... rolled my own loadpbm() function.
Then I guess you're done!
have fun, sorry this was harder than it should have been.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the SciPy-User
mailing list