From a595d0ae02a42e1fc87d8cf044243da08e39414c Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Wed, 19 Oct 2011 15:01:45 +0200 Subject: [PATCH] Add a convenient function --- itk/clitkCropLikeImageFilter.h | 9 +++++++++ itk/clitkCropLikeImageFilter.txx | 23 +++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/itk/clitkCropLikeImageFilter.h b/itk/clitkCropLikeImageFilter.h index 9281fca..9c12d78 100644 --- a/itk/clitkCropLikeImageFilter.h +++ b/itk/clitkCropLikeImageFilter.h @@ -100,6 +100,15 @@ namespace clitk { }; // end class //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- + // Convenient function + template + typename ImageType::Pointer + ResizeImageLike(const ImageType * input, + const itk::ImageBase * like, + typename ImageType::PixelType BG); + } // end namespace clitk //-------------------------------------------------------------------- diff --git a/itk/clitkCropLikeImageFilter.txx b/itk/clitkCropLikeImageFilter.txx index 73dd7a7..5a9696e 100644 --- a/itk/clitkCropLikeImageFilter.txx +++ b/itk/clitkCropLikeImageFilter.txx @@ -23,9 +23,6 @@ #include "clitkCommon.h" #include "clitkPasteImageFilter.h" -// itk -//#include "itkPasteImageFilter.h" - //-------------------------------------------------------------------- template clitk::CropLikeImageFilter:: @@ -244,5 +241,23 @@ GenerateData() { } //-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +template +typename ImageType::Pointer +clitk::ResizeImageLike(const ImageType * input, + const itk::ImageBase * like, + typename ImageType::PixelType backgroundValue) +{ + typedef clitk::CropLikeImageFilter CropFilterType; + typename CropFilterType::Pointer cropFilter = CropFilterType::New(); + cropFilter->SetInput(input); + cropFilter->SetCropLikeImage(like); + cropFilter->SetBackgroundValue(backgroundValue); + cropFilter->Update(); + return cropFilter->GetOutput(); +} +//-------------------------------------------------------------------- + -#endif //#define CLITKAUTOCROPFILTER +#endif //#define CLITKCROPLIKEIMAGEFILTER_TXX -- 2.47.1