[Image-SIG] Array to Image to Array

Max Erickson maxerickson at gmail.com
Tue Nov 7 12:16:29 CET 2006

"Chris S" <chrisspen at gmail.com> wrote:

> I'm trying to "smooth" a 2D array of floats by converting it to a
> PIL image, blurring it, then converting it back to an array.
> However, I can find no practical way to convert arrays to and
> from PIL. 
> I've found http://effbot.org/zone/pil-numpy.htm but it was
> written 8 years ago for Numeric and doesn't appear to work with
> the current version of Numpy and PIL. Does anyone know how to
> adapt this code to work correctly with the current libraries?

Change a.typecode() to a.dtype and import Numeric to from numpy.core 
import numeric. Fix numeric not to be capitalized.

I'm guessing a bit, I did a similar fix for an earlier version of 
numpy and a.dtype used to be a.dtypechar, but I think it should work.


More information about the Image-SIG mailing list