From 59c15f1e3261fa84d1fb7dd6e4da4ace67ca3d1f Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Mon, 24 Oct 2011 08:30:47 +0200 Subject: [PATCH] Add ResizeImageLike with region or bb --- itk/clitkCropLikeImageFilter.h | 17 ++++++++++++++++ itk/clitkCropLikeImageFilter.txx | 35 +++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/itk/clitkCropLikeImageFilter.h b/itk/clitkCropLikeImageFilter.h index 9c12d78..c8fae32 100644 --- a/itk/clitkCropLikeImageFilter.h +++ b/itk/clitkCropLikeImageFilter.h @@ -19,6 +19,10 @@ #ifndef CLITKCROPLIKEIMAGEFILTER_H #define CLITKCROPLIKEIMAGEFILTER_H +// clitk +#include "clitkBoundingBoxUtils.h" + +// itk #include namespace clitk { @@ -109,6 +113,19 @@ namespace clitk { const itk::ImageBase * like, typename ImageType::PixelType BG); + template + typename ImageType::Pointer + ResizeImageLike(const ImageType * input, + typename itk::ImageBase::RegionType * like, + typename ImageType::PixelType BG); + + template + typename ImageType::Pointer + ResizeImageLike(const ImageType * input, + typename itk::BoundingBox::Pointer bb, + typename ImageType::PixelType BG); + + } // end namespace clitk //-------------------------------------------------------------------- diff --git a/itk/clitkCropLikeImageFilter.txx b/itk/clitkCropLikeImageFilter.txx index 5a9696e..93644a5 100644 --- a/itk/clitkCropLikeImageFilter.txx +++ b/itk/clitkCropLikeImageFilter.txx @@ -259,5 +259,38 @@ clitk::ResizeImageLike(const ImageType * input, } //-------------------------------------------------------------------- - + +//-------------------------------------------------------------------- +template +typename ImageType::Pointer +clitk::ResizeImageLike(const ImageType * input, + typename itk::ImageBase::RegionType * region, + typename ImageType::PixelType backgroundValue) +{ + typename ImageType::Pointer output = ImageType::New(); + output->CopyInformation(input); + output->SetRegions(region); + output->Allocate(); + return clitk::ResizeImageLike(input, output, backgroundValue); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +typename ImageType::Pointer +clitk::ResizeImageLike(const ImageType * input, + typename itk::BoundingBox::Pointer bb, + typename ImageType::PixelType BG) +{ + typename ImageType::RegionType region; + clitk::ComputeRegionFromBB(input, bb, region); + typename ImageType::Pointer output = ImageType::New(); + output->CopyInformation(input); + output->SetRegions(region); + output->Allocate(); + return clitk::ResizeImageLike(input, output, BG); +} +//-------------------------------------------------------------------- + #endif //#define CLITKCROPLIKEIMAGEFILTER_TXX -- 2.47.1