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.
Thanks for looking at this!
-Mike
On Wed, 2008-07-02 at 23:56 +0200, Stéfan van der Walt wrote:
> Hi Mike
>
> 2008/7/2 Mike Sarahan <[EMAIL PROTECTED]>:
> > I'm trying to do phase reconstruction on images which involves switching
> > back and forth between Fourier space and real space. I'm trying to test
> > numpy (& scipy, for that matter) just to see if I can go back and forth.
> > After an FFT/iFFT, the resulting image is garbage. I'm using
> > numpy.fft.fftn, but I've also tried fft2, rfftn, rfft2, and the
> > corresponding inverse FFT's.
> >
> > >From looking at the matrices, it appears to be creating complex
> > components that aren't in the matrix prior to any FFT's. Real fft's
> > seem to add some small component to each value (<1). I'm using
> > Image.fromarray to convert arrays to images, and I'm working with 8-bit
> > grayscale images.
>
> Those components are very small!
>
> In [59]: x = (np.random.random((15,15)) * 255).astype(np.uint8)
>
> In [60]: np.fft.fft2(x).imag.sum()
> Out[60]: -2.5011104298755527e-12
>
> And you can see that the forward-reverse transformed values compare
> well to the original:
>
> In [61]: z = np.fft.ifft2(np.fft.fft2(x))
>
> In [62]: np.abs(x - z).sum()
> Out[62]: 2.5060395252422397e-11
>
> If you have bigger problems, send us a code snippet and we'll take a look.
>
> Regards
> Stéfan
> _______________________________________________
> Numpy-discussion mailing list
> [email protected]
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion