/*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv Authors belong to: - University of LYON http://www.universite-lyon.fr/ - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the copyright notices for more information. It is distributed under dual licence - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ===========================================================================**/ #ifndef clitkFilterGenericFilter_txx #define clitkFilterGenericFilter_txx /* ================================================= * @file clitkFilterGenericFilter.txx * @author * @date * * @brief * ===================================================*/ namespace clitk { //------------------------------------------------------------------- // Update with the number of dimensions //------------------------------------------------------------------- template void FilterGenericFilter::UpdateWithDim(std::string PixelType) { if (m_Verbose) std::cout << "Image was detected to be "<(); // } // else if(PixelType == "unsigned_short"){ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl; // UpdateWithDimAndPixelType(); // } // else if (PixelType == "unsigned_char"){ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl; // UpdateWithDimAndPixelType(); // } // else if (PixelType == "char"){ // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl; // UpdateWithDimAndPixelType(); // } // else { if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl; UpdateWithDimAndPixelType(); // } } //------------------------------------------------------------------- // Update with the number of dimensions and the pixeltype //------------------------------------------------------------------- template void FilterGenericFilter::UpdateWithDimAndPixelType() { // ImageTypes typedef itk::Image InputImageType; typedef itk::Image InternalImageType; typedef itk::Image OutputImageType; // Read the input typedef itk::ImageFileReader InputReaderType; typename InputReaderType::Pointer reader = InputReaderType::New(); reader->SetFileName( m_InputFileName); reader->Update(); typename InputImageType::Pointer input= reader->GetOutput(); // Filter typedef itk::ImageToImageFilter< InternalImageType, InternalImageType > ImageToImageFilterType; typename ImageToImageFilterType::Pointer filter; switch ( m_ArgsInfo.type_arg ){ case 0:{ typename itk::DerivativeImageFilter< InternalImageType,InternalImageType >::Pointer df = itk::DerivativeImageFilter::New(); //Set parameters df->SetDirection(m_ArgsInfo.direction_arg); df->SetOrder(m_ArgsInfo.order_arg); filter=df; if (m_Verbose) std::cout<<"Using the derivative image filter with order "<::Pointer gf = itk::GradientMagnitudeImageFilter::New(); //Set parameters gf->SetUseImageSpacingOn(); filter=gf; if (m_Verbose) std::cout<<"Using the gradient magnitude image filter... "<< std::endl; break; } case 2:{ switch ( m_ArgsInfo.projection_arg ){ case 0:{ //Sum typename itk::SumProjectionImageFilter< InternalImageType,InternalImageType >::Pointer pf = itk::SumProjectionImageFilter::New(); //Set parameters pf->SetProjectionDimension(m_ArgsInfo.direction_arg); filter=pf; if (m_Verbose) std::cout<<"Using the Sum projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<::Pointer pf = itk::MaximumProjectionImageFilter::New(); //Set parameters pf->SetProjectionDimension(m_ArgsInfo.direction_arg); filter=pf; if (m_Verbose) std::cout<<"Using the maximum intensity projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<::Pointer pf = itk::MinimumProjectionImageFilter::New(); //Set parameters pf->SetProjectionDimension(m_ArgsInfo.direction_arg); filter=pf; if (m_Verbose) std::cout<<"Using the minimum intensity projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<::Pointer pf = itk::IntensityWindowingImageFilter::New(); //Set parameters pf->SetWindowMinimum((InternalPixelType) m_ArgsInfo.inputMin_arg); pf->SetWindowMaximum((InternalPixelType) m_ArgsInfo.inputMax_arg); pf->SetOutputMinimum((InternalPixelType) m_ArgsInfo.outputMin_arg); pf->SetOutputMaximum((InternalPixelType) m_ArgsInfo.outputMax_arg); filter=pf; if (m_Verbose) std::cout<<"Using the window intensity image filter with the window min and max being " << m_ArgsInfo.inputMin_arg << " and "<< m_ArgsInfo.inputMax_arg <<" and the output min and max being "< ResamplerType; typedef itk::BSplineCenteredResampleImageFilterBase CenteredResamplerType; typedef itk::BSplineL2ResampleImageFilterBase L2ResamplerType; typedef itk::BSplineCenteredL2ResampleImageFilterBase CenteredL2ResamplerType; //ResamplerType if(m_ArgsInfo.resamplerType_arg==0) { typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, ResamplerType >::Pointer df = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, ResamplerType >::New(); df->SetSplineOrder(m_ArgsInfo.splineOrder_arg); filter=df; if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with Standard Resampler"<::Pointer df = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, CenteredResamplerType >::New(); df->SetSplineOrder(m_ArgsInfo.splineOrder_arg); filter=df; if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with Centered Resampler"<::Pointer df = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType,L2ResamplerType >::New(); df->SetSplineOrder(m_ArgsInfo.splineOrder_arg); filter=df; if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 Resampler"<::Pointer df = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType,CenteredL2ResamplerType >::New(); df->SetSplineOrder(m_ArgsInfo.splineOrder_arg); filter=df; if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 Centered Resampler"< NormalizeFilterType; typename NormalizeFilterType::Pointer df = NormalizeFilterType::New(); filter=df; if (m_Verbose) std::cout << "Normalizing image intensities to a zero mean and 1 SD (float!)..." << std::endl; break; } // case 6: { // typedef itk::AnisotropicDiffusionImageFilter FilterType; // typename FilterType::Pointer df = FilterType::New(); // df->SetConductanceParameter(m_ArgsInfo.cond_arg); // df->SetNumberOfIterations(m_ArgsInfo.iter_arg); // df->SetTimeStep(m_ArgsInfo.time_arg); // df->SetUseImageSpacing(true); // filter=df; // if (m_Verbose) std::cout << "Using the anisotropic diffusion image filter..." << std::endl; // break; // } case 7: { typedef itk::GradientAnisotropicDiffusionImageFilter FilterType; typename FilterType::Pointer df = FilterType::New(); df->SetConductanceParameter(m_ArgsInfo.cond_arg); df->SetNumberOfIterations(m_ArgsInfo.iter_arg); df->SetTimeStep(m_ArgsInfo.time_arg); df->SetUseImageSpacing(true); filter=df; if (m_Verbose) std::cout << "Using the gradient anisotropic diffusion image filter..." << std::endl; break; } case 8: { typedef itk::CurvatureAnisotropicDiffusionImageFilter FilterType; typename FilterType::Pointer df = FilterType::New(); df->SetConductanceParameter(m_ArgsInfo.cond_arg); df->SetNumberOfIterations(m_ArgsInfo.iter_arg); df->SetTimeStep(m_ArgsInfo.time_arg); df->SetUseImageSpacing(true); filter=df; if (m_Verbose) std::cout << "Using the Curvature anisotropic diffusion image filter..." << std::endl; break; } case 9: { typedef itk::CurvatureFlowImageFilter FilterType; typename FilterType::Pointer df = FilterType::New(); df->SetTimeStep(m_ArgsInfo.time_arg); df->SetUseImageSpacing(true); df->SetNumberOfIterations(m_ArgsInfo.iter_arg); filter=df; if (m_Verbose) std::cout << "Using the curvature flow image filter......" << std::endl; break; } }//end switch filterType //================================================================== //execute the filter filter->SetInput(input); if (m_Verbose)std::cout<<"Starting filter..."<Update(); } catch( itk::ExceptionObject & err ) { std::cerr << "ExceptionObject caught! Filter failed!" << std::endl; std::cerr << err << std::endl; return; } // Output typedef itk::ImageFileWriter WriterType; typename WriterType::Pointer writer = WriterType::New(); writer->SetFileName(m_ArgsInfo.output_arg); writer->SetInput(filter->GetOutput()); writer->Update(); } }//end clitk #endif //#define clitkFilterGenericFilter_txx