1 /*=========================================================================
5 Author : Joel Schaerer (joel.schaerer@insa-lyon.fr)
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 =========================================================================*/
26 #include <itkMaximumProjectionImageFilter.h>
28 #include "clitkCommon.h"
29 #include "vvSlicerManager.h"
32 #include "vvFromITK.h"
33 #include "vvMaximumIntensityProjection.h"
35 void vvMaximumIntensityProjection::Compute(vvSlicerManager * slicer_manager)
37 #define TRY_TYPE(TYPE) \
38 if (clitk::IsSameType<TYPE>(image->GetScalarTypeAsString())) { this->Update_WithPixelType<TYPE>(image); return; }
39 std::string list = clitk::CreateListOfTypes<short>();
40 vvImage::Pointer image=slicer_manager->GetSlicer(0)->GetImage();
43 std::cerr << "Error, I don't know the type '" << image->GetScalarTypeAsString() << "' for the input image. "
44 << std::endl << "Known types are " << list << std::endl;
49 template <class PixelType>
50 void vvMaximumIntensityProjection::Update_WithPixelType(vvImage::Pointer image)
52 switch(image->GetNumberOfDimensions())
55 Update_WithDimAndPixelType<PixelType,3>(image);
58 Update_WithDimAndPixelType<PixelType,4>(image);
61 DD("Error: dimension not handled.");
65 template <class PixelType,int Dim>
66 void vvMaximumIntensityProjection::Update_WithDimAndPixelType(vvImage::Pointer image)
68 typedef itk::Image<PixelType,Dim> ImageType;
69 typedef itk::Image<PixelType,Dim-1> OutputImageType;
70 typedef itk::MaximumProjectionImageFilter<ImageType,OutputImageType> FilterType;
71 typename FilterType::Pointer filter = FilterType::New();
72 filter->SetProjectionDimension(Dim-1);
73 typename ImageType::ConstPointer input = vvImageToITK<ImageType>(image);
74 filter->SetInput(input);
76 mOutputImage=vvImageFromITK<Dim-1,PixelType>(filter->GetOutput());