#if ITK_VERSION_MAJOR < 4
#include "itkVnlFFTRealToComplexConjugateImageFilter.h"
#else
#endif
#include <itksys/SystemTools.hxx>
#include "vnl/vnl_sample.h"
#include <math.h>
int main(int argc, char*argv[])
{
if(argc < 2)
{
std::cerr << "Required: filename" << std::endl;
return EXIT_FAILURE;
}
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
unsigned int powerOfTwo = 0;
for(unsigned int i = 0; i < 20; i++)
{
if(pow(2.0, static_cast<double>(i)) >= reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0] &&
pow(2.0, static_cast<double>(i)) >= reader->GetOutput()->GetLargestPossibleRegion().GetSize()[1])
{
powerOfTwo = i;
break;
}
}
size.
Fill(pow(2.0,static_cast<double>(powerOfTwo)));
FloatImageType::Pointer image = FloatImageType::New();
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
PasteImageFilterType;
destinationIndex.
Fill(0);
PasteImageFilterType::Pointer pasteFilter
= PasteImageFilterType::New ();
pasteFilter->SetSourceImage(reader->GetOutput());
pasteFilter->SetDestinationImage(image);
pasteFilter->SetSourceRegion(reader->GetOutput()->GetLargestPossibleRegion());
pasteFilter->SetDestinationIndex(destinationIndex);
pasteFilter->Update();
image->Graft(pasteFilter->GetOutput());
#if ITK_VERSION_MAJOR < 4
typedef itk::VnlFFTRealToComplexConjugateImageFilter<FloatImageType> FFTType;
#else
#endif
FFTType::Pointer fftFilter = FFTType::New();
fftFilter->SetInput(image);
RealFilterType::Pointer realFilter = RealFilterType::New();
realFilter->SetInput(fftFilter->GetOutput());
ImaginaryFilterType::Pointer imaginaryFilter = ImaginaryFilterType::New();
imaginaryFilter->SetInput(fftFilter->GetOutput());
ModulusFilterType::Pointer modulusFilter = ModulusFilterType::New();
modulusFilter->SetInput(fftFilter->GetOutput());
viewer.
AddImage(image.GetPointer(),
true,
itksys::SystemTools::GetFilenameName(argv[1]));
viewer.
AddImage(realFilter->GetOutput(),
true,
"Real");
viewer.
AddImage(imaginaryFilter->GetOutput(),
true,
"Imaginary");
viewer.
AddImage(modulusFilter->GetOutput(),
true,
"Magnitude");
return EXIT_SUCCESS;
}