1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
19 #include <itkMaximumProjectionImageFilter.h>
21 #include "clitkCommon.h"
22 #include "vvSlicerManager.h"
25 #include "vvFromITK.h"
26 #include "vvMaximumIntensityProjection.h"
28 void vvMaximumIntensityProjection::Compute(vvSlicerManager * slicer_manager)
30 #define TRY_TYPE(TYPE) \
31 if (clitk::IsSameType<TYPE>(image->GetScalarTypeAsString())) { this->Update_WithPixelType<TYPE>(image); return; }
32 std::string list = clitk::CreateListOfTypes<short>();
33 vvImage::Pointer image=slicer_manager->GetSlicer(0)->GetImage();
36 std::cerr << "Error, I don't know the type '" << image->GetScalarTypeAsString() << "' for the input image. "
37 << std::endl << "Known types are " << list << std::endl;
42 template <class PixelType>
43 void vvMaximumIntensityProjection::Update_WithPixelType(vvImage::Pointer image)
45 switch(image->GetNumberOfDimensions())
48 Update_WithDimAndPixelType<PixelType,3>(image);
51 Update_WithDimAndPixelType<PixelType,4>(image);
54 DD("Error: dimension not handled.");
58 template <class PixelType,int Dim>
59 void vvMaximumIntensityProjection::Update_WithDimAndPixelType(vvImage::Pointer image)
61 typedef itk::Image<PixelType,Dim> ImageType;
62 typedef itk::Image<PixelType,Dim-1> OutputImageType;
63 typedef itk::MaximumProjectionImageFilter<ImageType,OutputImageType> FilterType;
64 typename FilterType::Pointer filter = FilterType::New();
65 filter->SetProjectionDimension(Dim-1);
66 typename ImageType::ConstPointer input = vvImageToITK<ImageType>(image);
67 filter->SetInput(input);
69 mOutputImage=vvImageFromITK<Dim-1,PixelType>(filter->GetOutput());