target_link_libraries(clitkVectorImageToImage clitkCommon)
set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVectorImageToImage)
- WRAP_GGO(clitkNVectorImageTo4DImage_GGO_C clitkNVectorImageTo4DImage.ggo)
+ 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)
+ WRAP_GGO(clitk4DImageToNVectorImage_GGO_C clitk4DImageToNVectorImage.ggo)
+ add_executable(clitk4DImageToNVectorImage clitk4DImageToNVectorImage.cxx clitk4DImageToNVectorImageGenericFilter.cxx ${clitk4DImageToNVectorImage_GGO_C})
+ target_link_libraries(clitk4DImageToNVectorImage clitkCommon)
+ set(TOOLS_INSTALL ${TOOLS_INSTALL} clitk4DImageToNVectorImage)
+
add_executable(clitkMIP clitkMIP.cxx clitkMIPGenericFilter.cxx)
target_link_libraries(clitkMIP clitkMIPLib clitkCommon)
set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMIP)
--- /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 clitk4DImageToNVectorImage.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk
+#include "clitk4DImageToNVectorImage_ggo.h"
+#include "clitkIO.h"
+#include "clitk4DImageToNVectorImageGenericFilter.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+ // Init command line
+ GGO(clitk4DImageToNVectorImage, args_info);
+ CLITK_INIT;
+
+ // Filter
+ clitk::FourDImageToNVectorImageGenericFilter::Pointer genericFilter=clitk::FourDImageToNVectorImageGenericFilter::New();
+
+ genericFilter->SetArgsInfo(args_info);
+ genericFilter->Update();
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+#File clitk4DImageToNVectorImage.ggo
+package "clitk4DImageToNVectorImage"
+version "1.0"
+purpose "Convert the 4th dimension of a 4D Image into a VectorPixel 3D 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
+
--- /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 clitk4DImageToNVectorImageGenericFilter_cxx
+#define clitk4DImageToNVectorImageGenericFilter_cxx
+
+/* =================================================
+ * @file clitk4DImageToNVectorImageGenericFilter.cxx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitk4DImageToNVectorImageGenericFilter.h"
+
+
+namespace clitk
+{
+
+
+ //-----------------------------------------------------------
+ // Constructor
+ //-----------------------------------------------------------
+ FourDImageToNVectorImageGenericFilter::FourDImageToNVectorImageGenericFilter()
+ {
+ m_Verbose=false;
+ m_InputFileName="";
+ }
+
+
+ //-----------------------------------------------------------
+ // Update
+ //-----------------------------------------------------------
+ void FourDImageToNVectorImageGenericFilter::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 clitk4DImageToNVectorImageGenericFilter_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 clitk4DImageToNVectorImageGenericFilter_h
+#define clitk4DImageToNVectorImageGenericFilter_h
+
+/* =================================================
+ * @file clitk4DImageToNVectorImageGenericFilter.h
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitk4DImageToNVectorImage_ggo.h"
+
+//itk include
+#include "itkLightObject.h"
+
+namespace clitk
+{
+
+
+ class ITK_EXPORT FourDImageToNVectorImageGenericFilter : public itk::LightObject
+ {
+ public:
+ //----------------------------------------
+ // ITK
+ //----------------------------------------
+ typedef FourDImageToNVectorImageGenericFilter 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( 4DImageToNVectorImageGenericFilter, LightObject );
+
+
+ //----------------------------------------
+ // Typedefs
+ //----------------------------------------
+
+
+ //----------------------------------------
+ // Set & Get
+ //----------------------------------------
+ void SetArgsInfo(const args_info_clitk4DImageToNVectorImage & a)
+ {
+ m_ArgsInfo=a;
+ m_Verbose=m_ArgsInfo.verbose_flag;
+ m_InputFileName=m_ArgsInfo.input_arg;
+ }
+
+
+ //----------------------------------------
+ // Update
+ //----------------------------------------
+ void Update();
+
+ protected:
+
+ //----------------------------------------
+ // Constructor & Destructor
+ //----------------------------------------
+ FourDImageToNVectorImageGenericFilter();
+ ~FourDImageToNVectorImageGenericFilter() {};
+
+
+ //----------------------------------------
+ // 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_clitk4DImageToNVectorImage m_ArgsInfo;
+ bool m_Verbose;
+ std::string m_InputFileName;
+
+ };
+
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitk4DImageToNVectorImageGenericFilter.txx"
+#endif
+
+#endif // #define clitk4DImageToNVectorImageGenericFilter_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 clitk4DImageToNVectorImageGenericFilter_txx
+#define clitk4DImageToNVectorImageGenericFilter_txx
+
+/* =================================================
+ * @file clitk4DImageToNVectorImageGenericFilter.txx
+ * @author
+ * @date
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "itkComposeImageFilter.h"
+#include "itkExtractImageFilter.h"
+
+namespace clitk
+{
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions
+ //-------------------------------------------------------------------
+ template<unsigned int Dimension>
+ void
+ FourDImageToNVectorImageGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
+ {
+ if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
+
+ if (PixelType == "short") {
+ UpdateWithDimAndPixelType<Dimension, short>();
+ } else if (PixelType == "unsigned short") {
+ UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ } else if (PixelType == "unsigned_short") {
+ UpdateWithDimAndPixelType<Dimension, unsigned short>();
+ } else if (PixelType == "char") {
+ UpdateWithDimAndPixelType<Dimension, char>();
+ } else if (PixelType == "unsigned_char") {
+ UpdateWithDimAndPixelType<Dimension, unsigned char>();
+ } else if (PixelType == "int") {
+ UpdateWithDimAndPixelType<Dimension, int>();
+ } else if (PixelType == "unsigned_int") {
+ UpdateWithDimAndPixelType<Dimension, unsigned int>();
+ } else if (PixelType == "double") {
+ UpdateWithDimAndPixelType<Dimension, double>();
+ } else if (PixelType == "float") {
+ UpdateWithDimAndPixelType<Dimension, float>();
+ } else {
+ std::cerr << "Error, pixel type : \"" << PixelType << "\" unknown !" << std::endl;
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Update with the number of dimensions and the pixeltype
+ //-------------------------------------------------------------------
+ template <unsigned int Dimension, class PixelType>
+ void
+ FourDImageToNVectorImageGenericFilter::UpdateWithDimAndPixelType()
+ {
+ // ImageTypes
+ typedef itk::Image<PixelType, Dimension> InputImageType;
+ typedef itk::Image<PixelType, Dimension-1> MedianImageType;
+ typedef itk::VectorImage<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();
+ std::string fileName=m_ArgsInfo.output_arg;
+
+ //Filter
+ typedef itk::ComposeImageFilter<MedianImageType> ImageToVectorImageFilterType;
+ typename ImageToVectorImageFilterType::Pointer imageToVectorImageFilter = ImageToVectorImageFilterType::New();
+ typedef itk::ExtractImageFilter<InputImageType, MedianImageType> ExtractFilterType;
+ typename ExtractFilterType::Pointer extractFilter = ExtractFilterType::New();
+ extractFilter->SetDirectionCollapseToSubmatrix();
+ typedef itk::ImageFileWriter<OutputImageType> WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+
+ extractFilter->SetInput(input);
+ typename InputImageType::SizeType size;
+ for (unsigned int nbDimension=0; nbDimension<Dimension-1; ++nbDimension)
+ {
+ size[nbDimension] = input->GetLargestPossibleRegion().GetSize(nbDimension);
+ }
+ size[Dimension-1] = 0;
+ typename MedianImageType::Pointer tempImage = MedianImageType::New();
+
+ //Extract All "time" slices
+ for (unsigned int nbSlice=0; nbSlice<input->GetLargestPossibleRegion().GetSize(Dimension-1); ++nbSlice)
+ {
+ typename InputImageType::RegionType desiredRegion;
+ typename InputImageType::IndexType index;
+ index.Fill(0);
+ index[Dimension-1]=nbSlice;
+ desiredRegion.SetSize(size);
+ extractFilter->SetInput(input);
+ desiredRegion.SetIndex(index);
+ extractFilter->SetExtractionRegion(desiredRegion);
+ extractFilter->Update();
+ tempImage = extractFilter->GetOutput();
+ tempImage->DisconnectPipeline();
+ extractFilter->Update();
+ imageToVectorImageFilter->SetInput(nbSlice, tempImage);
+ }
+
+ imageToVectorImageFilter->Update();
+
+ // Output
+ writer->SetInput(imageToVectorImageFilter->GetOutput());
+ writer->SetFileName(fileName);
+ writer->Update();
+ }
+}//end clitk
+
+#endif //#define clitk4DImageToNVectorImageGenericFilter_txx