X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMaximumIntensityProjection.cxx;h=077a884cab2932e48a4070d0439020e733181a73;hb=b7ea297944fd0df19cbaa19889cdb25673d93095;hp=08f0dcddf0955412b76bda548c3994e2fa8e0ac3;hpb=0b7c9b1e1215634b02cbd38d4e4ba101d6111ba8;p=clitk.git diff --git a/vv/vvMaximumIntensityProjection.cxx b/vv/vvMaximumIntensityProjection.cxx index 08f0dcd..077a884 100644 --- a/vv/vvMaximumIntensityProjection.cxx +++ b/vv/vvMaximumIntensityProjection.cxx @@ -1,7 +1,7 @@ /*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: + Authors belong to: - University of LYON http://www.universite-lyon.fr/ - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr @@ -24,47 +24,53 @@ #include "vvToITK.h" #include "vvFromITK.h" #include "vvMaximumIntensityProjection.h" +#include void vvMaximumIntensityProjection::Compute(vvSlicerManager * slicer_manager) { #define TRY_TYPE(TYPE) \ if (clitk::IsSameType(image->GetScalarTypeAsString())) { this->Update_WithPixelType(image); return; } - std::string list = clitk::CreateListOfTypes(); - vvImage::Pointer image=slicer_manager->GetSlicer(0)->GetImage(); - TRY_TYPE(float); - TRY_TYPE(short); - std::cerr << "Error, I don't know the type '" << image->GetScalarTypeAsString() << "' for the input image. " - << std::endl << "Known types are " << list << std::endl; - exit(0); + std::string list = clitk::CreateListOfTypes(); + vvImage::Pointer image=slicer_manager->GetSlicer(0)->GetImage(); + TRY_TYPE(float); + TRY_TYPE(double); + TRY_TYPE(int); + TRY_TYPE(unsigned int); + TRY_TYPE(short); + TRY_TYPE(unsigned short); + TRY_TYPE(char); + TRY_TYPE(unsigned char); + QMessageBox::warning(0,"Unsupported image type",QString("Error, I don't know the type")+QString(image->GetScalarTypeAsString().c_str()) +QString("' for the input image.\nKnown types are ") + QString(list.c_str())); + error=true; #undef TRY_TYPE } template void vvMaximumIntensityProjection::Update_WithPixelType(vvImage::Pointer image) { - switch(image->GetNumberOfDimensions()) - { - case 3: - Update_WithDimAndPixelType(image); - break;; - case 4: - Update_WithDimAndPixelType(image); - break;; - default: - DD("Error: dimension not handled."); - } + switch(image->GetNumberOfDimensions()) { + case 3: + Update_WithDimAndPixelType(image); + break;; + case 4: + Update_WithDimAndPixelType(image); + break;; + default: + QMessageBox::warning(0,"Unsupported image dimension",QString("Unsupported image dimension. Supported dimensions are 3 and 4")); + error=true; + } } template void vvMaximumIntensityProjection::Update_WithDimAndPixelType(vvImage::Pointer image) { - typedef itk::Image ImageType; - typedef itk::Image OutputImageType; - typedef itk::MaximumProjectionImageFilter FilterType; - typename FilterType::Pointer filter = FilterType::New(); - filter->SetProjectionDimension(Dim-1); - typename ImageType::ConstPointer input = vvImageToITK(image); - filter->SetInput(input); - filter->Update(); - mOutputImage=vvImageFromITK(filter->GetOutput()); + typedef itk::Image ImageType; + typedef itk::Image OutputImageType; + typedef itk::MaximumProjectionImageFilter FilterType; + typename FilterType::Pointer filter = FilterType::New(); + filter->SetProjectionDimension(Dim-1); + typename ImageType::ConstPointer input = vvImageToITK(image); + filter->SetInput(input); + filter->Update(); + mOutputImage=vvImageFromITK(filter->GetOutput()); }