From: Gauthier Bouilhol Date: Fri, 31 Aug 2012 13:06:15 +0000 (+0200) Subject: VF supported (SR) X-Git-Tag: v1.3.0~11^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d4e10d50db2d54d9dc65965085b1080ed2e00d6a;p=clitk.git VF supported (SR) --- diff --git a/tools/clitkSplitImageGenericFilter.cxx b/tools/clitkSplitImageGenericFilter.cxx index 5a5e246..55bf7a8 100644 --- a/tools/clitkSplitImageGenericFilter.cxx +++ b/tools/clitkSplitImageGenericFilter.cxx @@ -36,13 +36,54 @@ clitk::SplitImageGenericFilter::SplitImageGenericFilter(): } //-------------------------------------------------------------------- - //-------------------------------------------------------------------- template void clitk::SplitImageGenericFilter::InitializeImageType() { ADD_DEFAULT_IMAGE_TYPES(Dim); - //ADD_VEC_IMAGE_TYPE(Dim, 3,float); + ADD_VEC_IMAGE_TYPE(Dim, 3,float); +} +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +template +typename clitk::SplitImageGenericFilter::PngConversion::OutputPngImagePointer +clitk::SplitImageGenericFilter::PngConversion::Do(double window, + double level, + ImagePointer input) +{ + static const unsigned int PixelDimension = itk::PixelTraits::Dimension; + return this->Do(window, level, input, static_cast< PixelDimType *>(NULL) ); +} +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +template +template +typename clitk::SplitImageGenericFilter::PngConversion::OutputPngImagePointer +clitk::SplitImageGenericFilter::PngConversion::Do(double window, + double level, + ImagePointer input, + PixelDimType *) +{ + clitkExceptionMacro("Png conversion is not implemented for vector fields"); + return NULL; +} +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +template +typename clitk::SplitImageGenericFilter::PngConversion::OutputPngImagePointer +clitk::SplitImageGenericFilter::PngConversion::Do(double window, + double level, + ImagePointer input, + PixelDimType<1> *) +{ + typedef itk::IntensityWindowingImageFilter< ImageType, OutputPngImageType > CastFilterType; + typename CastFilterType::Pointer cast = CastFilterType::New(); + cast->SetWindowLevel(window, level); + cast->SetInput(input); + return cast->GetOutput(); } //-------------------------------------------------------------------- @@ -80,13 +121,11 @@ void clitk::SplitImageGenericFilter::UpdateWithInputImageType() filter->SetExtractionRegion(extracted_region); filter->Update(); if(this->m_Png){ - typedef itk::Image< unsigned char, ImageType::ImageDimension-1 > OutputPngImageType; - typedef itk::IntensityWindowingImageFilter< OutputImageType, OutputPngImageType > CastFilterType; - typename CastFilterType::Pointer cast = CastFilterType::New(); - cast->SetWindowLevel(this->m_Window, this->m_Level); - cast->SetInput(filter->GetOutput()); + PngConversion png; SetOutputFilename(base_filename+"_"+ss.str()+".png"); - SetNextOutput(cast->GetOutput()); + typename PngConversion::OutputPngImagePointer output; + output = png.Do(this->m_Window, this->m_Level, filter->GetOutput()); + this->template SetNextOutput::OutputPngImageType>(output); } else { SetOutputFilename(base_filename+"_"+ss.str()+".mhd"); diff --git a/tools/clitkSplitImageGenericFilter.h b/tools/clitkSplitImageGenericFilter.h index dfdd0e7..4b6d676 100644 --- a/tools/clitkSplitImageGenericFilter.h +++ b/tools/clitkSplitImageGenericFilter.h @@ -67,6 +67,23 @@ namespace clitk { void UpdateWithInputImageType(); protected: + template + class PngConversion + { + public: + typedef typename ImageType::Pointer ImagePointer; + typedef itk::Image< unsigned char, ImageType::ImageDimension > OutputPngImageType; + typedef typename OutputPngImageType::Pointer OutputPngImagePointer; + OutputPngImagePointer Do(double window, double level, ImagePointer input); + private: + template struct PixelDimType {}; + template OutputPngImagePointer Do(double window, + double level, + ImagePointer input, + PixelDimType *); + OutputPngImagePointer Do(double window, double level, ImagePointer input, PixelDimType<1> *); + }; + template void InitializeImageType(); int mSplitDimension; bool m_Verbose;