/*========================================================================= Program: vv Language: C++ Author : Joel Schaerer (joel.schaerer@insa-lyon.fr) Copyright (C) 2008 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr CREATIS-LRMN http://www.creatis.insa-lyon.fr This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . =========================================================================*/ #include #include #include "clitkCommon.h" #include "vvSlicerManager.h" #include "vvSlicer.h" #include "vvToITK.h" #include "vvFromITK.h" #include "vvMaximumIntensityProjection.h" 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); #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."); } } 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()); }