int main( int argc, char * argv [] )
{
if( argc < 4 )
{
std::cerr << "Usage: " << argv[0] << " inputScalarImage inputMaskImage";
std::cerr << " outputFilteredImage" << std::endl;
}
typedef float InputPixelType;
typedef unsigned char MaskPixelType;
InputReaderType::Pointer inputReader = InputReaderType::New();
MaskReaderType::Pointer maskReader = MaskReaderType::New();
inputReader->SetFileName( argv[1] );
maskReader->SetFileName( argv[2] );
FFTFilterType::Pointer fftFilter = FFTFilterType::New();
fftFilter->SetInput( inputReader->GetOutput() );
typedef FFTFilterType::OutputImageType SpectralImageType;
MaskImageType,
SpectralImageType > MaskFilterType;
MaskFilterType::Pointer maskFilter = MaskFilterType::New();
maskFilter->SetInput1( fftFilter->GetOutput() );
maskFilter->SetInput2( maskReader->GetOutput() );
SpectralWriterType::Pointer spectralWriter = SpectralWriterType::New();
spectralWriter->SetFileName("filteredSpectrum.mhd");
spectralWriter->SetInput( maskFilter->GetOutput() );
spectralWriter->Update();
SpectralImageType > IFFTFilterType;
IFFTFilterType::Pointer fftInverseFilter = IFFTFilterType::New();
fftInverseFilter->SetInput( maskFilter->GetOutput() );
try
{
fftInverseFilter->Update();
}
{
std::cerr << "Error: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( argv[3] );
writer->SetInput( fftInverseFilter->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << "Error writing the real image: " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}