Pixelvalues of an image in a 2D double* pointer for calculating FFT_2D
I want to calculate the FFT of an image, I read the image, and the ITK SmartPointer is called “imagen”. The input of the function I use for calculating the FFT (fftw_plan_dft_r2c_2d) need a 2D double* pointer as input. Because of that I do that:
double *in = (double*) imagen.GetPointer(); // conversión de i开发者_StackOverflow中文版tk.smartpointer --> double*.
But when I try to access the values of pixels of the image they are not defined The pixeltype of ‘image’ is double:
typedef double PixelType;
typedef itk::Image < PixelType, 2> ImageType;
ImageType::Pointer imagen;
And the image is read from a frame trhoug the user interface using Qt:
imagen=ui.imageframe->imagereader;
Can anyone help me with this? I need to have the values of the image in a 2D double* pointer for calculating the fft.
Cheers and thanks for your help in advanced!
Antonio Gómez Barquero
EDITED
I have solved my problem, is posted below, but now the problem is to convert the result to a 2D matrix without knowing the second dimension of it until the execution time, because the image is loaded during the execution not during compilation, any tips?? THANKS!
SOLUTION
double *in;
ImageType::IndexType pixelIndex;
ImageType::PixelType pixelValue;
for ( int x = 0; x<ancho; x++){
for (int y = 0; y<alto; y++){
pixelIndex[0] = x; //x position
pixelIndex[1] = y; //y position
ImageType::PixelType pixel2 = imagen->GetPixel(pixelIndex);
*(in+x*ancho+y) = static_cast <double> (imagen->GetPixel(pixelIndex));
}
}
ITK also has FFT's available.
Example of the framework is: http://www.vtk.org/Wiki/ITK/Examples/SpectralAnalysis/VnlFFTRealToComplexConjugateImageFilter
There is another very very similar options to use FFTW. Just build ITK with the USE_FFTW flag set to on. (NOTE : The USE_FFTW option is under "Advanced" settings curing the cmake configuration step).
From ITK Mailing List: http://old.nabble.com/how-to-use-FFTW-with-ITK-td19531608.html
精彩评论