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"
27 #include <QMessageBox>
28 #include <QInputDialog>
30 void vvMaximumIntensityProjection::Compute(vvSlicerManager * slicer_manager)
32 mDimension = QInputDialog::getInteger(0, "MIP Axis","Choose the axis along which to perform the MIP",0,0,\
33 slicer_manager->GetImage()->GetNumberOfDimensions()-1,1);
34 #define TRY_TYPE(TYPE) \
35 if (clitk::IsSameType<TYPE>(image->GetScalarTypeAsITKString())) { this->Update_WithPixelType<TYPE>(image); return; }
36 std::string list = clitk::CreateListOfTypes<short>();
37 vvImage::Pointer image=slicer_manager->GetSlicer(0)->GetImage();
41 TRY_TYPE(unsigned int);
43 TRY_TYPE(unsigned short);
45 TRY_TYPE(unsigned char);
46 QMessageBox::warning(0,"Unsupported image type",
47 QString("Error, I don't know the type")+QString(image->GetScalarTypeAsITKString().c_str()) +QString("' for the input image.\nKnown types are ") + QString(list.c_str()));
52 template <class PixelType>
53 void vvMaximumIntensityProjection::Update_WithPixelType(vvImage::Pointer image)
55 switch(image->GetNumberOfDimensions()) {
57 Update_WithDimAndPixelType<PixelType,3>(image);
60 Update_WithDimAndPixelType<PixelType,4>(image);
63 QMessageBox::warning(0,"Unsupported image dimension",QString("Unsupported image dimension. Supported dimensions are 3 and 4"));
68 template <class PixelType,int Dim>
69 void vvMaximumIntensityProjection::Update_WithDimAndPixelType(vvImage::Pointer image)
71 typedef itk::Image<PixelType,Dim> ImageType;
72 typedef itk::Image<PixelType,Dim-1> OutputImageType;
73 typedef itk::MaximumProjectionImageFilter<ImageType,OutputImageType> FilterType;
74 typename FilterType::Pointer filter = FilterType::New();
75 filter->SetProjectionDimension(mDimension);
76 typename ImageType::ConstPointer input = vvImageToITK<ImageType>(image);
77 filter->SetInput(input);
79 mOutputImage=vvImageFromITK<Dim-1,PixelType>(filter->GetOutput());