+++ /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 clitkAnd.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkAnd_ggo.h"
-#include "clitkIO.h"
-#include "clitkAndGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkAnd, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::AndGenericFilter::Pointer genericFilter=clitk::AndGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkAnd.ggo
-package "clitkAnd"
-version "1.0"
-purpose "Perform a pixel-wise logical AND between to images"
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "input2" j "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 clitkAndGenericFilter_cxx
-#define clitkAndGenericFilter_cxx
-
-/* =================================================
- * @file clitkAndGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkAndGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- AndGenericFilter::AndGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void AndGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- // else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkAndGenericFilter_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 clitkAndGenericFilter_h
-#define clitkAndGenericFilter_h
-
-/* =================================================
- * @file clitkAndGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkAnd_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkAndImageFilter.h"
-#include "itkCastImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT AndGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef AndGenericFilter 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( AndGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkAnd & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- AndGenericFilter();
- ~AndGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkAnd m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkAndGenericFilter.txx"
-#endif
-
-#endif // #define clitkAndGenericFilter_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 clitkAndGenericFilter_txx
-#define clitkAndGenericFilter_txx
-
-/* =================================================
- * @file clitkAndGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- AndGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- AndGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<int, Dimension> InternalImageType;
- typedef itk::Image<PixelType, Dimension> 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();
-
- // 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<InputImageType, InternalImageType> 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..."<<std::endl;
-
- // Cast
- typedef itk::CastImageFilter<InternalImageType, OutputImageType> OutputCastImageFilterType;
- typename OutputCastImageFilterType::Pointer caster3= OutputCastImageFilterType::New();
- caster3->SetInput(andFilter->GetOutput());
- typename OutputImageType::Pointer output =caster3->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkAndGenericFilter_txx