add_executable(clitkVectorImageToImage clitkVectorImageToImage.cxx clitkVectorImageToImageGenericFilter.cxx ${clitkVectorImageToImage_GGO_C})
target_link_libraries(clitkVectorImageToImage clitkCommon)
set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVectorImageToImage)
+
+ WRAP_GGO(clitkNVectorImageTo4DImage_GGO_C clitkNVectorImageTo4DImage.ggo)
+ add_executable(clitkNVectorImageTo4DImage clitkNVectorImageTo4DImage.cxx clitkNVectorImageTo4DImageGenericFilter.cxx ${clitkNVectorImageTo4DImage_GGO_C})
+ target_link_libraries(clitkNVectorImageTo4DImage clitkCommon)
+ set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkNVectorImageTo4DImage)
add_executable(clitkMIP clitkMIP.cxx clitkMIPGenericFilter.cxx)
target_link_libraries(clitkMIP clitkMIPLib clitkCommon)
--- /dev/null
+/*=========================================================================
+ 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
+===========================================================================**/
+
+/* =================================================
+ * @file clitkNVectorImageTo4DImage.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitkNVectorImageTo4DImage_ggo.h"
+#include "clitkIO.h"
+#include "clitkNVectorImageTo4DImageGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitkNVectorImageTo4DImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::NVectorImageTo4DImageGenericFilter::Pointer genericFilter=clitk::NVectorImageTo4DImageGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitkNVectorImageTo4DImage.ggo
+package "clitkNVectorImageTo4DImage"
+version "1.0"
+purpose "Convert all pixel channels of the image into a 4D image"
+
+option "config" - "Config file" string no
+option "verbose" v "Verbose" flag off
+
+option "input" i "Input image filename" string yes
+option "output" o "Output image filename" string yes
+option "componentIndex" c "Component index to extract" int no default="0"
+
--- /dev/null
+/*=========================================================================
+ 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 clitkNVectorImageTo4DImageFilter_h
+#define clitkNVectorImageTo4DImageFilter_h
+
+/* =================================================
+ * @file clitkNVectorImageTo4DImageFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+
+//itk include
+#include "itkImageToImageFilter.h"
+
+namespace clitk
+{
+
+ template <class InputImageType, class OutputImageType>
+ class ITK_EXPORT NVectorImageTo4DImageFilter :
+ public itk::ImageToImageFilter<InputImageType, OutputImageType>
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef NVectorImageTo4DImageFilter Self;
+ typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( NVectorImageTo4DImageFilter, ImageToImageFilter );
+
+ /** Dimension of the domain space. */
+ itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
+ itkStaticConstMacro(OutputImageDimension, unsigned int, Superclass::OutputImageDimension);
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+ typedef typename OutputImageType::RegionType OutputImageRegionType;
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ itkBooleanMacro(Verbose);
+ itkSetMacro( Verbose, bool);
+ itkGetConstReferenceMacro( Verbose, bool);
+ itkSetMacro(ComponentIndex, unsigned int);
+ itkGetConstMacro(ComponentIndex, unsigned int);
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ NVectorImageTo4DImageFilter();
+ ~NVectorImageTo4DImageFilter() {};
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadId );
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ bool m_Verbose;
+ unsigned int m_ComponentIndex;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkNVectorImageTo4DImageFilter.txx"
+#endif
+
+#endif // #define clitkNVectorImageTo4DImageFilter_h
+
+
--- /dev/null
+/*=========================================================================
+ 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 clitkNVectorImageTo4DImageFilter_txx
+#define clitkNVectorImageTo4DImageFilter_txx
+
+/* =================================================
+ * @file clitkNVectorImageTo4DImageFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Constructor
+ //-------------------------------------------------------------------
+ template<class InputImageType, class OutputImageType>
+ NVectorImageTo4DImageFilter<InputImageType, OutputImageType>::NVectorImageTo4DImageFilter()
+ {
+ m_Verbose=false;
+ m_ComponentIndex=0;
+ }
+
+
+ //-------------------------------------------------------------------
+ // Generate Data
+ //-------------------------------------------------------------------
+ template<class InputImageType, class OutputImageType>
+ void NVectorImageTo4DImageFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadId)
+ {
+ // Iterators
+ typename OutputImageType::Pointer output=this->GetOutput();
+ typename InputImageType::ConstPointer input=this->GetInput();
+
+ typedef itk::ImageRegionConstIterator<InputImageType> InputIteratorType;
+ InputIteratorType inputIt (input, outputRegionForThread);
+
+ typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType;
+ OutputIteratorType outputIt (output, outputRegionForThread);
+
+ while(! inputIt.IsAtEnd() )
+ {
+ //outputIt.Set(inputIt.Get()[m_ComponentIndex]);
+ ++outputIt;
+ ++inputIt;
+ }
+ }
+
+
+}//end clitk
+
+#endif //#define clitkNVectorImageTo4DImageFilter_txx
--- /dev/null
+/*=========================================================================
+ 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 clitkNVectorImageTo4DImageGenericFilter_cxx
+#define clitkNVectorImageTo4DImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitkNVectorImageTo4DImageGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkNVectorImageTo4DImageGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ NVectorImageTo4DImageGenericFilter::NVectorImageTo4DImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void NVectorImageTo4DImageGenericFilter::Update()
+ {
+ // Read the Dimension and PixelType
+ int Dimension, Components;
+ std::string PixelType;
+ ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
+
+ // Call UpdateWithDim
+ if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
+ else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
+ else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
+ else
+ {
+ std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
+ return;
+ }
+ }
+
+
+} //end clitk
+
+#endif //#define clitkNVectorImageTo4DImageGenericFilter_cxx
--- /dev/null
+/*=========================================================================
+ 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 clitkNVectorImageTo4DImageGenericFilter_h
+#define clitkNVectorImageTo4DImageGenericFilter_h
+
+/* =================================================
+ * @file clitkNVectorImageTo4DImageGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkNVectorImageTo4DImage_ggo.h"
+#include "clitkNVectorImageTo4DImageFilter.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT NVectorImageTo4DImageGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef NVectorImageTo4DImageGenericFilter Self;
+ typedef itk::LightObject Superclass;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ // Method for creation through the object factory
+ itkNewMacro(Self);
+
+ // Run-time type information (and related methods)
+ itkTypeMacro( NVectorImageTo4DImageGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitkNVectorImageTo4DImage & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ NVectorImageTo4DImageGenericFilter();
+ ~NVectorImageTo4DImageGenericFilter() {};
+
+
+ //----------------------------------------
+ // Templated members
+ //----------------------------------------
+ template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
+ template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
+
+
+ //----------------------------------------
+ // Data members
+ //----------------------------------------
+ args_info_clitkNVectorImageTo4DImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkNVectorImageTo4DImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkNVectorImageTo4DImageGenericFilter_h
--- /dev/null
+/*=========================================================================
+ 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 clitkNVectorImageTo4DImageGenericFilter_txx
+#define clitkNVectorImageTo4DImageGenericFilter_txx
+
+/* =================================================
+ * @file clitkNVectorImageTo4DImageGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "itkVectorImageToImageAdaptor.h"
+#include <sstream>
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ NVectorImageTo4DImageGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float..." << std::endl;
+ UpdateWithDimAndPixelType<Dimension, float >();
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ NVectorImageTo4DImageGenericFilter::UpdateWithDimAndPixelType()
+ {
+ // ImageTypes
+ typedef itk::VectorImage<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension+1> OutputImageType;
+
+ // Read the input
+ typedef itk::ImageFileReader<InputImageType> InputReaderType;
+ typename InputReaderType::Pointer reader = InputReaderType::New();
+ reader->SetFileName( m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input= reader->GetOutput();
+
+ //Filter
+ typedef itk::VectorImageToImageAdaptor<PixelType, Dimension> ImageAdaptorType;
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
+ typename OutputImageType::Pointer output = OutputImageType::New();
+ typename WriterType::Pointer writer = WriterType::New();
+
+ adaptor->SetExtractComponentIndex(0);
+ adaptor->SetImage(input);
+ std::string fileName=m_ArgsInfo.output_arg;
+
+ //Create the output
+ typename OutputImageType::IndexType index;
+ index.Fill(0);
+ typename OutputImageType::SizeType size;
+ for (unsigned int pixelDim=0; pixelDim<input->GetNumberOfComponentsPerPixel(); ++pixelDim)
+ {
+ size[pixelDim]=input->GetLargestPossibleRegion().GetSize(pixelDim);
+ }
+ size[Dimension]=input->GetNumberOfComponentsPerPixel();
+ typename OutputImageType::RegionType region;
+ region.SetSize(size);
+ region.SetIndex(index);
+ output->SetRegions(region);
+ output->Allocate();
+ writer->SetInput(output);
+
+ //Copy each channel
+ for (unsigned int pixelDim=0; pixelDim<input->GetNumberOfComponentsPerPixel(); ++pixelDim)
+ {
+ adaptor->SetExtractComponentIndex(pixelDim);
+
+ itk::ImageRegionIterator<InputImageType> imageIterator(input,input->GetLargestPossibleRegion());
+
+ while(!imageIterator.IsAtEnd())
+ {
+ typename OutputImageType::IndexType indexVector;
+ indexVector.Fill(0);
+ for (unsigned int indexDim=0; indexDim<Dimension; ++indexDim)
+ {
+ indexVector[indexDim]=imageIterator.GetIndex().GetElement(indexDim);
+ }
+ indexVector[Dimension]=pixelDim;
+
+ output->SetPixel(indexVector, adaptor->GetPixel(imageIterator.GetIndex()));
+ ++imageIterator;
+ }
+ }
+ // Output
+ writer->SetFileName(fileName);
+ writer->Update();
+ }
+}//end clitk
+
+#endif //#define clitkNVectorImageTo4DImageGenericFilter_txx