/*------------------------------------------------------------------------- Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. -------------------------------------------------------------------------*/ #ifndef clitkSplitImageGenericFilter_TXX #define clitkSplitImageGenericFilter_TXX //This is where you put the actual implementation #include #include //-------------------------------------------------------------------- template void clitk::SplitImageGenericFilter::UpdateWithDim(std::string PixelType, int Components) { 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(); } } else if (Components==3) { if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl; UpdateWithDimAndPixelType >(); } else std::cerr<<"Number of components is "< void clitk::SplitImageGenericFilter::UpdateWithDimAndPixelType() { // Read input typedef itk::Image ImageType; typedef itk::Image OutputImageType; typename ImageType::Pointer input = clitk::readImage(mInputFilenames[0], mIOVerbose); typedef itk::ExtractImageFilter FilterType; typename FilterType::Pointer filter= FilterType::New(); filter->SetInput(input); typename ImageType::SizeType size=input->GetLargestPossibleRegion().GetSize(); size[mSplitDimension]=0; typename ImageType::RegionType extracted_region; extracted_region.SetSize(size); filter->SetExtractionRegion(extracted_region); filter->Update(); typename ImageType::IndexType index=input->GetLargestPossibleRegion().GetIndex(); std::string base_filename=GetOutputFilename(); unsigned int number_of_output_images=input->GetLargestPossibleRegion().GetSize()[mSplitDimension]; for (unsigned int i=0;iSetExtractionRegion(extracted_region); filter->Update(); SetOutputFilename(base_filename+"_"+ss.str()+".mhd"); typename OutputImageType::Pointer output=filter->GetOutput(); SetNextOutput(output); } } //-------------------------------------------------------------------- #endif //#define clitkSplitImageGenericFilter_TXX