[Numpy-discussion] FFT's & IFFT's on images

Stéfan van der Walt stefan@sun.ac...
Wed Jul 2 18:00:57 CDT 2008

Hi Mike

2008/7/3 Mike Sarahan <msarahan@gmail.com>:
> I agree that the components are very small, and in a numeric sense, I
> wouldn't worry at all about them, but the image result is simply noise,
> albeit periodic-looking noise.
> Here's a code snippet:
> ----------------------------------------
> import numpy,Image
> img=Image.open('LlamaTeeth.jpg')
> arr=numpy.asarray(img)
> fftarr=numpy.fft.fftn(arr)
> ifftarr=numpy.fft.ifftn(fftarr)
> img2=Image.fromarray(ifftarr)
> img2.show()
> ----------------------------------------

There is a bug in PIL, so you must make sure that your array is of
type uint8 before you convert it to an Image, i.e.

ifftarr = ifftarr.astype(np.uint8)
imt2 = Image.fromarray(ifftarr)

Hope that works.


More information about the Numpy-discussion mailing list