[Insight-users] Fwd: FFT
alexandre govignon
govignon.alexandre at gmail.com
Fri Mar 28 11:21:05 EDT 2008
Fot the image i have no website, sorry... But it's just one colored
(grey) image.
---------- Forwarded message ----------
From: alexandre govignon <govignon.alexandre at gmail.com>
Date: 28 mars 2008 16:20
Subject: Re: [Insight-users] FFT
To: Luis Ibanez <luis.ibanez at kitware.com>, insight-users at itk.org
Hi Luis,
Thanks for reply,
VnlFFT and FFTW have the same following in code, except replace
itkVnlFFT by itkFFTW
My code with VNL is:
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif
// Software Guide : BeginCodeSnippet
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkVnlFFTRealToComplexConjugateImageFilter.h"
#include "itkComplexToRealImageFilter.h"
#include "itkComplexToImaginaryImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"
#include <iostream>
int main(int argc, char * argv[])
{
// FFT
if( argc < 3 )
{
std::cerr << "Usage: " << argv[0] << " inputScalarImage
outputRealPartOfComplexImage outputRealImaginaryPartOfComplexImage" <<
std::endl;
}
typedef float PixelType;
const unsigned int Dimension = 2;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::FFTRealToComplexConjugateImageFilter< PixelType,
Dimension > FFTFilterType; //Filtre FFT r√(c)el √† complexe
conjugu√(c)
FFTFilterType::Pointer fftFilter = FFTFilterType::New(); //
instanciation Filtre FFT
typedef itk::ImageFileReader< ImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
fftFilter->SetInput( reader->GetOutput() );
try
{
fftFilter->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Error: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
typedef FFTFilterType::OutputImageType ComplexImageType;
typedef itk::ImageFileWriter< ComplexImageType > ComplexWriterType;
ComplexWriterType::Pointer complexWriter = ComplexWriterType::New();
complexWriter->SetFileName("complexImage.mhd");
complexWriter->SetInput( fftFilter->GetOutput() );
try
{
complexWriter->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Error: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
typedef itk::ComplexToRealImageFilter< ComplexImageType, ImageType
> RealFilterType;
RealFilterType::Pointer realFilter = RealFilterType::New();
realFilter->SetInput( fftFilter->GetOutput() );
typedef unsigned char WritePixelType;
typedef itk::Image< WritePixelType, Dimension > WriteImageType;
typedef itk::RescaleIntensityImageFilter<ImageType, WriteImageType
> RescaleFilterType; // on d√(c)clare le r√(c)echelonnage
RescaleFilterType::Pointer intensityRescaler =
RescaleFilterType::New(); // instanciation du
pointeur sur le r√(c)echelonneur
intensityRescaler->SetInput( realFilter->GetOutput() );
intensityRescaler->SetOutputMinimum( 0 );
intensityRescaler->SetOutputMaximum( 255 );
typedef itk::ImageFileWriter< WriteImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( argv[2] );
writer->SetInput( intensityRescaler->GetOutput() );
try
{
writer->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Error writing the real image: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Regards,
Alexandre
2008/3/28, Luis Ibanez <luis.ibanez at kitware.com>:
>
> Hi Alexandre,
>
> Have you tried the follwing examples ?
>
>
> Insight/Examples/Filtering/
> FFTDirectInverse.cxx
> FFTDirectInverse2.cxx
> FFTImageFilter.cxx
> FFTImageFilterFourierDomainFiltering.cxx
>
> They contribute three tests to the Nightly Dashboards.
>
>
> --
>
>
> Can you post to the list the code that you are currently using ?
>
> Can you post in a public web site one of the typical images
> that you want to process ?
>
>
> Please let us know,
>
>
> Thanks
>
>
> Luis
>
>
> -------------------------
>
> alexandre govignon wrote:
> > I am desperate, i m trying to make a FFT and it doesn't work. I have
> > tried is the same as the beginning. I obtained image in one scale of
> > grey with VnlFFT and with FFTW. Moreover FFTW transform square image in
> > rectangular image. Are there anybody who can help me?
> >
> > --
> > Cordialement,
> > Alexandre Govignon.
> >
> >
>
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
>
--
Cordialement,
Alexandre Govignon.
More information about the Insight-users
mailing list