Image Filtering Using Fourier Transform

Posted on Posted in Android Applications, Android Tutorials, OpenCV Tutorials, Projects, Qt Tutorials, Tutorials

In Machine Vision there is a magical trick that involves Fourier transformation of an image and I would like to share it with you today. I learned this long ago from a professor of mine but I remember back then there was not much experience and information about this on the web. Also there was no program that allowed experimenting with Fourier transformation of Images, until I developed an Android application titled Image Transformer, using OpenCV and Qt, which allows you to do just that.

Normally, to filter or change an image you would apply some kind of filter to the image and observe the changes in the resulting image. There is a second and much more interesting method which is done by using a Fourier transformation on the image, applying a filter (anything possible) and then converting back to the original image (this is also called reverse Fourier transform). Picture below explains it all:

Image Transformer

The power behind this phenomenon might not be obvious at first but if you experiment with it more and more, you will notice it. For example in the picture above what I have done is actually eliminating horizontal lines in an image by applying a mask to the Fourier transformation of the image. Normally it would sound impossible for someone working with machine vision but using Fourier transform you can see that it is quite easy.

Below are the original pictures I used to created the picture above. Checkout and see for yourself that even by applying a rough and not precise mask I was able to get rid of horizontal lines. There are many hidden aspects about this, yet to be found, and you can start experimenting for yourself by downloading and using Image Transformer.

Please also let me know if you find any issues with the app or if you come up with any useful ideas that you think might help other researchers benefit from this app.

4 thoughts on “Image Filtering Using Fourier Transform

  1. Hello, I’m trying to use OpenCV to apply the dft algorithm into images capture by the camera phone but I’m having no success. Have you used this algorithm:

    Mine is crashing at:
    Core.add(magI, Mat.ones(padded.rows(), padded.cols(), CvType.CV_64FC1), magI2)

    If you are interested in helping me, there is a post in stack overflow:

    thank you.

    1. Hi Pedro,
      I’d love to help you but I am not using Java that much. Most of what you see on my website is about Qt and OpenCV (both in C++) The link to Frourier function that you provided is also C++ version of it which I use.
      With that being said, you can search use the menu at the top to get to Android or OpenCV tutorials section.
      Also you can search for “JNI” using the search box at the top right. Here it is:
      Let me know if this helped you.

      1. Hello amin,
        Thank you for the quick answer. I also tried using jni and my app still crashing. I’ll read your tutorials and try again with. Jni!
        First, do you think it is possible to apply on real time capture? (that was the first thing I tried to do).

        Thank you again.

Leave a Reply

Your email address will not be published. Required fields are marked *