penguinV icon indicating copy to clipboard operation
penguinV copied to clipboard

Add an example application for FFT code usage

Open ihhub opened this issue 6 years ago • 6 comments

We would like to add an example for FFT code usage like. As a reference we could use Gaussian filtering. We need to do these steps:

  1. Create a directory examples/fft
  2. Include src/fft.cpp, src/fft.h, src/filtering.h, src/filtering.cpp and src/thirdparty/kissfft header files into the project
  3. Create VS project file (you could copy from examples/blob_detection folder for example
  4. Create make file for the project
  5. Create CMake file for the project
  6. Modify examples/CMakeLists.txt file to include new project
  7. Modify examples/makefile file to include new project

You could refer to any of existing example projects as a reference.

The code for this example project should include file loading, filter usage and file saving.

ihhub avatar Jan 03 '20 08:01 ihhub

Hello @ihhub Is this issue still available? If yes, i would be interested to work on it.

theoniko avatar Jan 09 '20 16:01 theoniko

Hi @theoniko , surely you can take this issue. Please be free to ask any questions for clarification of the task requirements.

ihhub avatar Jan 11 '20 05:01 ihhub

Hello @ihhub Could you be a little more specific about the expected example content? As far as i know the FFT image displays the absolute value (or complex magnitude) of the spatial frequencies found in the image.

theoniko avatar Jan 18 '20 19:01 theoniko

We could use FFT to make Gaussian blur:

std::vector<float> filter;
Image_Function::GetGaussianKernel( filter, input.width(), input.height(), 5, 2 );

FFT::ComplexData imageFFT( image );
FFT::ComplexData filterFFT;
filterFFT.resize( input.width(), input.height() );
filterFFT.set( filter );

FFT::FFTExecutor fftExecutor( input.width(), input.height() );

fftExecutor.directTransform( imageFFT );
fftExecutor.directTransform( filterFFT );
fftExecutor.complexMultiplication( imageFFT, filterFFT, imageFFT );
fftExecutor.inverseTransform( imageFFT );

const penguinV::Image output = imageFFT.get();

I think it should work.

ihhub avatar Jan 22 '20 03:01 ihhub

@theoniko I've created a pull request to simplify above code from:

FFT::ComplexData filterFFT;
filterFFT.resize( input.width(), input.height() );
filterFFT.set( filter );

into:

FFT::ComplexData filterFFT( filter, input.width(), input.height() );

ihhub avatar Jan 22 '20 03:01 ihhub

I will apply those changes at the weekend.

theoniko avatar Jan 23 '20 05:01 theoniko