]> Creatis software - clitk.git/blob - tools/clitkMIPGenericFilter.cxx
Allow to display in all directions for images with size 2 and 3 in 3rd direction
[clitk.git] / tools / clitkMIPGenericFilter.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef clitkMIPGenericFilter_cxx
19 #define clitkMIPGenericFilter_cxx
20
21 /* =================================================
22  * @file   clitkMIPGenericFilter.cxx
23  * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
24  * @date   29 june 2009
25  *
26  * @brief
27  *
28  ===================================================*/
29
30 #include "clitkMIPGenericFilter.h"
31
32 // itk include
33 #include <itkImage.h>
34 #include <itkMaximumProjectionImageFilter.h>
35
36 #include <clitkCommon.h>
37
38 namespace clitk
39 {
40
41 //--------------------------------------------------------------------
42 MIPGenericFilter::MIPGenericFilter():
43   ImageToImageGenericFilter<Self>("MIP")
44 {
45   InitializeImageType<3>();
46   InitializeImageType<4>();
47 }
48 //--------------------------------------------------------------------
49
50
51 //--------------------------------------------------------------------
52 template<unsigned int Dim>
53 void MIPGenericFilter::InitializeImageType()
54 {
55   ADD_DEFAULT_IMAGE_TYPES(Dim);
56 }
57 //--------------------------------------------------------------------
58
59
60 //--------------------------------------------------------------------
61 void MIPGenericFilter::SetArgsInfo(const args_info_type & a)
62 {
63   mArgsInfo=a;
64   SetIOVerbose(mArgsInfo.verbose_flag);
65   if (mArgsInfo.imagetypes_given && mArgsInfo.imagetypes_flag)
66     this->PrintAvailableImageTypes();
67   if (mArgsInfo.input_given) {
68     SetInputFilename(mArgsInfo.input_arg);
69   }
70   if (mArgsInfo.output_given) {
71     SetOutputFilename(mArgsInfo.output_arg);
72   }
73 }
74 //--------------------------------------------------------------------
75
76
77 //--------------------------------------------------------------------
78 // Update with the number of dimensions and the pixeltype
79 //--------------------------------------------------------------------
80 template<class InputImageType>
81 void
82 MIPGenericFilter::UpdateWithInputImageType()
83 {
84   typedef typename InputImageType::PixelType PixelType;
85   const int Dim = InputImageType::ImageDimension;
86   typedef itk::Image<PixelType,Dim> ImageType;
87   typedef itk::Image<PixelType,Dim-1> OutputImageType;
88   typedef itk::MaximumProjectionImageFilter<ImageType,OutputImageType> FilterType;
89   typename FilterType::Pointer filter = FilterType::New();
90   filter->SetProjectionDimension(mArgsInfo.dimension_arg);
91   typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
92   filter->SetInput(input);
93   filter->Update();
94   this->template SetNextOutput<OutputImageType>(filter->GetOutput());
95 }
96 //--------------------------------------------------------------------
97
98
99 }//end clitk
100
101 #endif  //#define clitkMIPGenericFilter_cxx