From: David Sarrut Date: Mon, 24 Oct 2011 06:30:47 +0000 (+0200) Subject: Add ResizeImageLike with region or bb X-Git-Tag: v1.3.0~174^2~29 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=59c15f1e3261fa84d1fb7dd6e4da4ace67ca3d1f;p=clitk.git Add ResizeImageLike with region or bb --- 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