[SciPy-user] signal.medfilt
Zachary Pincus
zachary.pincus at yale.edu
Thu Oct 16 08:22:14 EDT 2008
Hi Priya,
I think the problem may be that you aren't properly reading in the
images... unless you've got some other code that is overriding the
builtin python 'file' function, then the following simply reads in the
bits from a png file into a string, without decoding/decompressing/etc
the file into a numpy array:
> img = file('girl.png','rb').read()
As such, it's no surprise that a function which works on numpy arrays
is choking when fed a string.
You'll need to get some sort of image IO library to read PNGs. My
suggestion would be to look into PIL, the Python Imaging Library,
which can read images and be used to produce numpy arrays from them.
Once you are able to read in images, I also suggest looking at
scipy.ndimage, which provides useful image manipulation tools.
Zach
On Oct 16, 2008, at 4:53 AM, priya_tmsi wrote:
>
> I am trying to write a code for median filter using scipy
> the following is my code
>
> from numpy import *
> import ImageFilter
> from scipy import *
> import scipy.signal as signal
> img = file('girl.png','rb').read()
> imgDest=signal.medfilt(img)
> f1 = file( 'pygirl.png').write(imgDest)
>
> I get the following error on running this code
>
> Traceback (most recent call last):
> File "medfilt.py", line 6, in ?
> imgDest=signal.medfilt(img)
> File "/usr/lib/python2.4/site-packages/scipy/signal/
> signaltools.py", line
> 232, in medfilt
> return sigtools._order_filterND(volume,domain,order)
> ValueError: data type must provide an itemsize
>
>
> Can any one help please...:,(:,(
>
> --
> View this message in context: http://www.nabble.com/signal.medfilt-tp20009033p20009033.html
> Sent from the Scipy-User mailing list archive at Nabble.com.
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
More information about the SciPy-User
mailing list