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

Robert Kern robert.kern@gmail....
Wed Jul 2 17:49:20 CDT 2008

On Wed, Jul 2, 2008 at 17:14, Mike Sarahan <msarahan@gmail.com> wrote:
> 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()
> ----------------------------------------
> Please try it on an image that you have lying around.

Image.fromarray() does not know much about numpy dtypes other than
uint8, bool_, uint32, and float32. Cast (the real component of) the
array to a uint8 array and then use Image.fromarray().

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco

More information about the Numpy-discussion mailing list