X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkAndGenericFilter.txx;fp=segmentation%2FclitkAndGenericFilter.txx;h=87be72309c3a02713de6ca6b1b46011ed3868b72;hb=2f5b335da5621bdfc86cb594cc667d0929f4d8e3;hp=0000000000000000000000000000000000000000;hpb=e61455caad373a138edde0716ce5a556f4d1a624;p=clitk.git diff --git a/segmentation/clitkAndGenericFilter.txx b/segmentation/clitkAndGenericFilter.txx new file mode 100755 index 0000000..87be723 --- /dev/null +++ b/segmentation/clitkAndGenericFilter.txx @@ -0,0 +1,127 @@ +/*========================================================================= + 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://oncora1.lyon.fnclcc.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 clitkAndGenericFilter_txx +#define clitkAndGenericFilter_txx + +/* ================================================= + * @file clitkAndGenericFilter.txx + * @author + * @date + * + * @brief + * + ===================================================*/ + + +namespace clitk +{ + + //------------------------------------------------------------------- + // Update with the number of dimensions + //------------------------------------------------------------------- + template + void + AndGenericFilter::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 + AndGenericFilter::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(); + + // Read the second input + typename InputReaderType::Pointer reader2 = InputReaderType::New(); + reader2->SetFileName( m_ArgsInfo.input2_arg); + reader2->Update(); + typename InputImageType::Pointer input2= reader2->GetOutput(); + + + // Cast + typedef itk::CastImageFilter InputCastImageFilterType; + typename InputCastImageFilterType::Pointer caster= InputCastImageFilterType::New(); + caster->SetInput(input); + typename InputCastImageFilterType::Pointer caster2= InputCastImageFilterType::New(); + caster->SetInput(input2); + + // Filter + typedef itk::AndImageFilter< InternalImageType , InternalImageType , InternalImageType> AndFilterType; + typename AndFilterType::Pointer andFilter = AndFilterType::New(); + andFilter->SetInput1(caster->GetOutput()); + andFilter->SetInput2(caster2->GetOutput()); + if (m_Verbose) std::cout<<"Performing a logical AND..."< OutputCastImageFilterType; + typename OutputCastImageFilterType::Pointer caster3= OutputCastImageFilterType::New(); + caster3->SetInput(andFilter->GetOutput()); + typename OutputImageType::Pointer output =caster3->GetOutput(); + + // Output + typedef itk::ImageFileWriter WriterType; + typename WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(m_ArgsInfo.output_arg); + writer->SetInput(output); + writer->Update(); + + } + + +}//end clitk + +#endif //#define clitkAndGenericFilter_txx