]> Creatis software - clitk.git/blob - vv/vvMaximumIntensityProjection.cxx
removed headers
[clitk.git] / vv / vvMaximumIntensityProjection.cxx
1 #include <itkImage.h>
2 #include <itkMaximumProjectionImageFilter.h>
3
4 #include "clitkCommon.h"
5 #include "vvSlicerManager.h"
6 #include "vvSlicer.h"
7 #include "vvToITK.h"
8 #include "vvFromITK.h"
9 #include "vvMaximumIntensityProjection.h"
10
11 void vvMaximumIntensityProjection::Compute(vvSlicerManager * slicer_manager)
12 {
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();
17     TRY_TYPE(float);
18     TRY_TYPE(short);
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;
21     exit(0);
22 #undef TRY_TYPE
23 }
24
25 template <class PixelType>
26 void vvMaximumIntensityProjection::Update_WithPixelType(vvImage::Pointer image)
27 {
28     switch(image->GetNumberOfDimensions())
29     {
30         case 3:
31             Update_WithDimAndPixelType<PixelType,3>(image);
32             break;;
33         case 4:
34             Update_WithDimAndPixelType<PixelType,4>(image);
35             break;;
36         default:
37             DD("Error: dimension not handled.");
38     }
39 }
40
41 template <class PixelType,int Dim>
42 void vvMaximumIntensityProjection::Update_WithDimAndPixelType(vvImage::Pointer image)
43 {
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);
51     filter->Update();
52     mOutputImage=vvImageFromITK<Dim-1,PixelType>(filter->GetOutput());
53 }