]> Creatis software - clitk.git/blobdiff - itk/clitkCropLikeImageFilter.h
Add ResizeImageLike with region or bb
[clitk.git] / itk / clitkCropLikeImageFilter.h
index 4ceadc1698e068959b986b3f7b0b6f8efc5d8c8f..c8fae32891eef1c3a7b1f305fcf4e3fbb716cb06 100644 (file)
@@ -3,7 +3,7 @@
 
   Authors belong to: 
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
   This software is distributed WITHOUT ANY WARRANTY; without even
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-  ======================================================================-====*/
+  ===========================================================================**/
 
 #ifndef CLITKCROPLIKEIMAGEFILTER_H
 #define CLITKCROPLIKEIMAGEFILTER_H
 
+// clitk
+#include "clitkBoundingBoxUtils.h"
+
+// itk
 #include <itkImageToImageFilter.h>
 
 namespace clitk {
@@ -30,9 +34,7 @@ namespace clitk {
   //--------------------------------------------------------------------
   
   template <class ImageType>
-  class ITK_EXPORT CropLikeImageFilter: 
-    public itk::ImageToImageFilter<ImageType, ImageType> {
-
+  class ITK_EXPORT CropLikeImageFilter: public itk::ImageToImageFilter<ImageType, ImageType> {
   public:
     /** Standard class typedefs. */
     typedef CropLikeImageFilter                            Self;
@@ -52,25 +54,34 @@ namespace clitk {
     typedef typename ImageType::PixelType    PixelType;
     typedef typename ImageType::RegionType   RegionType;
     typedef typename ImageType::PointType    PointType;
+    typedef typename ImageType::IndexType    IndexType;
+    typedef typename ImageType::SizeType     SizeType;
 
-    /** Input image to crop */
-    void SetInput(const ImageType * image);
-    
     /** Image filename for Crop Like */
     void SetCropLikeFilename(std::string f);
     void SetCropLikeImage(const itk::ImageBase<ImageType::ImageDimension> * like);
     void SetCropLikeImage(const itk::ImageBase<ImageType::ImageDimension> * like, int axe);
 
+    // Set Background if 'like' is greater than input
+    itkSetMacro(BackgroundValue, PixelType);
+    itkGetConstMacro(BackgroundValue, PixelType); 
+
     /** ImageDimension constants */
     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
-    
+
+    // I dont want to verify inputs information
+    virtual void VerifyInputInformation() { }
+
   protected:
     CropLikeImageFilter();
     virtual ~CropLikeImageFilter() {}
     
     virtual void GenerateOutputInformation();
     virtual void GenerateData();
+    virtual void GenerateInputRequestedRegion();
     
+    PixelType m_BackgroundValue;
+    RegionType m_OutputRegion;
     RegionType m_Region;
     std::string m_LikeFilename;
     bool m_LikeFilenameIsGiven;
@@ -78,6 +89,14 @@ namespace clitk {
     const itk::ImageBase<ImageDimension> * m_LikeImage;
     std::vector<bool> m_CropAlongThisDimension;
     
+    PointType m_StartPoint;         // start point in physical world
+    IndexType m_StartSourceIndex;   // start index in "source" image 
+    IndexType m_StartDestIndex;     // start index in "destination" image 
+    
+    PointType m_StopPoint;         // stop point in physical world
+    IndexType m_StopSourceIndex;   // stop index in "source" image 
+    IndexType m_StopDestIndex;     // stop index in "destination" image 
+    
   private:
     CropLikeImageFilter(const Self&); //purposely not implemented
     void operator=(const Self&); //purposely not implemented
@@ -85,6 +104,28 @@ namespace clitk {
   }; // end class
   //--------------------------------------------------------------------
 
+
+  //--------------------------------------------------------------------
+  // Convenient function 
+  template<class ImageType>
+  typename ImageType::Pointer
+  ResizeImageLike(const ImageType * input,
+                  const itk::ImageBase<ImageType::ImageDimension> * like, 
+                  typename ImageType::PixelType BG);
+
+  template<class ImageType>
+  typename ImageType::Pointer
+  ResizeImageLike(const ImageType * input,
+                  typename itk::ImageBase<ImageType::ImageDimension>::RegionType * like, 
+                  typename ImageType::PixelType BG);
+
+  template<class ImageType>
+  typename ImageType::Pointer
+  ResizeImageLike(const ImageType * input, 
+                  typename itk::BoundingBox<unsigned long, ImageType::ImageDimension>::Pointer bb, 
+                  typename ImageType::PixelType BG);
+
+
 } // end namespace clitk
 //--------------------------------------------------------------------