2 #include <itkMaximumProjectionImageFilter.h>
4 #include "clitkCommon.h"
5 #include "vvSlicerManager.h"
9 #include "vvMaximumIntensityProjection.h"
11 void vvMaximumIntensityProjection::Compute(vvSlicerManager * slicer_manager)
13 #define TRY_TYPE(TYPE) \
14 if (clitk::IsSameType<TYPE>(image->GetScalarTypeAsString())) { this->Update_WithPixelType<TYPE>(image); return; }
15 std::string list = clitk::CreateListOfTypes<short>();
16 vvImage::Pointer image=slicer_manager->GetSlicer(0)->GetImage();
19 std::cerr << "Error, I don't know the type '" << image->GetScalarTypeAsString() << "' for the input image. "
20 << std::endl << "Known types are " << list << std::endl;
25 template <class PixelType>
26 void vvMaximumIntensityProjection::Update_WithPixelType(vvImage::Pointer image)
28 switch(image->GetNumberOfDimensions())
31 Update_WithDimAndPixelType<PixelType,3>(image);
34 Update_WithDimAndPixelType<PixelType,4>(image);
37 DD("Error: dimension not handled.");
41 template <class PixelType,int Dim>
42 void vvMaximumIntensityProjection::Update_WithDimAndPixelType(vvImage::Pointer image)
44 typedef itk::Image<PixelType,Dim> ImageType;
45 typedef itk::Image<PixelType,Dim-1> OutputImageType;
46 typedef itk::MaximumProjectionImageFilter<ImageType,OutputImageType> FilterType;
47 typename FilterType::Pointer filter = FilterType::New();
48 filter->SetProjectionDimension(Dim-1);
49 typename ImageType::ConstPointer input = vvImageToITK<ImageType>(image);
50 filter->SetInput(input);
52 mOutputImage=vvImageFromITK<Dim-1,PixelType>(filter->GetOutput());