scikit-image fft

629 views
Skip to first unread message

Christopher

unread,
Oct 16, 2014, 2:54:08 PM10/16/14
to scikit...@googlegroups.com
Hi all,

Discovered sci-image recently, and I like it so far. Right now I am basically trying to do an fft, filter out certain frequencies, and then back transform it to an image. My first thought was to use fft, but I can't find an fft function in the docs. I see that numpy has an fft function, but running that on a sci-kit image gives unpleasant errors. Is there perhaps a better method for this than fft? Any suggestions?

chris

Juan Nunez-Iglesias

unread,
Oct 16, 2014, 6:00:05 PM10/16/14
to scikit...@googlegroups.com
Hi Chris,

One of our main selling points is that we interop seamlessly with numpy. Doing an fft is one of those interops! Indeed it should "just work". Can you post more details about the error you're seeing?

Welcome! =)

Juan.




--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christopher

unread,
Oct 16, 2014, 7:14:59 PM10/16/14
to scikit...@googlegroups.com
Thanks Juan for the response!

It appears that the problem was that numpy fft returns a complex array, which gave an error when trying to display it. By extracting only the real parts of the array, it seems to work fine. This is a sample of what I was trying to do:

import numpy
from numpy import fft
from skimage import io, data
import matplotlib.pyplot as plot


im
= data.coffee()
f
= fft.fft2(im)
f2
= fft.ifft2(f)
r
= numpy.real(f2)
plot
.imshow(r)
plot
.show()




Thanks again

Stéfan van der Walt

unread,
Oct 16, 2014, 9:52:26 PM10/16/14
to scikit-image

Hi Chris

Welcome to the list!

On Oct 16, 2014 10:26 PM, "Christopher" <spa...@gmail.com> wrote:
>
> Discovered sci-image recently, and I like it so far. Right now I am basically trying to do an fft, filter out certain frequencies, and then back transform it to an image. My first thought was to use fft, but I can't find an fft function in the docs. I see that numpy has an fft function, but running that on a sci-kit image gives unpleasant errors. Is there perhaps a better method for this than fft? Any suggestions?

Have a look at the exercise for the FFT chapter in the scipy lecture notes:

http://scipy-lectures.github.io/intro/scipy.html#id4

This is very close to what you're trying to do.

Regards
Stéfan

Reply all
Reply to author
Forward
0 new messages