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

Mike Sarahan msarahan@gmail....
Wed Jul 2 18:28:32 CDT 2008


Beautiful!  Thanks Stefan!  It was the PIL bug.

Thanks for all the replies.
-Mike

On Thu, 2008-07-03 at 01:00 +0200, Stéfan van der Walt wrote:
> 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.
> 
> Cheers
> Stéfan
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion



More information about the Numpy-discussion mailing list