X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkSUVPeakGenericFilter.txx;h=8bf1f00f224e043d72535186f448d470b1d7fcd6;hb=ae015f09e2fa0ebc736d24b37c9ed6c1ca0cb5b2;hp=498b09b6ae786836e47d7597b05c57b34357759d;hpb=29b40d25daee279757fb44b7e2ecfdb38fd6c6f2;p=clitk.git diff --git a/tools/clitkSUVPeakGenericFilter.txx b/tools/clitkSUVPeakGenericFilter.txx index 498b09b..8bf1f00 100644 --- a/tools/clitkSUVPeakGenericFilter.txx +++ b/tools/clitkSUVPeakGenericFilter.txx @@ -19,6 +19,9 @@ #define CLITKSUVPEAKGENERICFILTER_TXX #include "clitkImageCommon.h" +#include "clitkCropLikeImageFilter.h" +#include "clitkResampleImageWithOptionsFilter.h" + #include namespace clitk @@ -75,6 +78,34 @@ void SUVPeakGenericFilter::UpdateWithInputImageType() typename MaskImageType::Pointer mask; if(mArgsInfo.mask_given) { mask = this->template GetInput(1); + // Check mask sampling/size + if (!HaveSameSizeAndSpacing(mask, input)) { + if (mArgsInfo.allow_resize_flag) { + if (mArgsInfo.verbose_flag) { + std::cout << "Resize mask image like input" << std::endl; + } + typedef clitk::ResampleImageWithOptionsFilter ResamplerType; + typename ResamplerType::Pointer resampler = ResamplerType::New(); + resampler->SetInput(mask); //By default the interpolation in NN, Ok for mask + resampler->SetOutputSpacing(input->GetSpacing()); + resampler->SetOutputOrigin(mask->GetOrigin()); + resampler->SetGaussianFilteringEnabled(false); + resampler->Update(); + mask = resampler->GetOutput(); + + typedef clitk::CropLikeImageFilter FilterType; + typename FilterType::Pointer crop = FilterType::New(); + crop->SetInput(mask); + crop->SetCropLikeImage(input); + crop->Update(); + mask = crop->GetOutput(); + + } + else { + std::cerr << "Mask image has a different size/spacing than input. Abort. (Use option --allow_resize)" << std::endl; + exit(-1); + } + } } else { mask = MaskImageType::New();