]> Creatis software - clitk.git/blobdiff - itk/clitkCropLikeImageFilter.txx
Add ResizeImageLike with region or bb
[clitk.git] / itk / clitkCropLikeImageFilter.txx
index 73dd7a7d1532f0f885d1a35f71296145b9691f9f..93644a57c57f9a4a664de713aaab5524b603b06d 100644 (file)
@@ -23,9 +23,6 @@
 #include "clitkCommon.h"
 #include "clitkPasteImageFilter.h"
 
-// itk
-//#include "itkPasteImageFilter.h"
-
 //--------------------------------------------------------------------
 template <class ImageType>
 clitk::CropLikeImageFilter<ImageType>::
@@ -244,5 +241,56 @@ GenerateData() {
 }
 //--------------------------------------------------------------------
    
-#endif //#define CLITKAUTOCROPFILTER
+
+//--------------------------------------------------------------------
+template<class ImageType>
+typename ImageType::Pointer
+clitk::ResizeImageLike(const ImageType * input,                       
+                       const itk::ImageBase<ImageType::ImageDimension> * like, 
+                       typename ImageType::PixelType backgroundValue) 
+{
+  typedef clitk::CropLikeImageFilter<ImageType> CropFilterType;
+  typename CropFilterType::Pointer cropFilter = CropFilterType::New();
+  cropFilter->SetInput(input);
+  cropFilter->SetCropLikeImage(like);
+  cropFilter->SetBackgroundValue(backgroundValue);
+  cropFilter->Update();
+  return cropFilter->GetOutput();  
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ImageType>
+typename ImageType::Pointer
+clitk::ResizeImageLike(const ImageType * input,                       
+                       typename itk::ImageBase<ImageType::ImageDimension>::RegionType * region, 
+                       typename ImageType::PixelType backgroundValue) 
+{
+  typename ImageType::Pointer output = ImageType::New();
+  output->CopyInformation(input);
+  output->SetRegions(region);
+  output->Allocate();
+  return clitk::ResizeImageLike<ImageType>(input, output, backgroundValue);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ImageType>
+typename ImageType::Pointer
+clitk::ResizeImageLike(const ImageType * input, 
+                       typename itk::BoundingBox<unsigned long, ImageType::ImageDimension>::Pointer bb, 
+                       typename ImageType::PixelType BG)
+{
+  typename ImageType::RegionType region;
+  clitk::ComputeRegionFromBB<ImageType>(input, bb, region);
+  typename ImageType::Pointer output = ImageType::New();
+  output->CopyInformation(input);
+  output->SetRegions(region);
+  output->Allocate();
+  return clitk::ResizeImageLike<ImageType>(input, output, BG);   
+}
+//--------------------------------------------------------------------
+
+#endif //#define CLITKCROPLIKEIMAGEFILTER_TXX