]> Creatis software - bbtk.git/blob - packages/itk/src/bbitkImageRegion.h
#2959 BBTK Feature New Normal - new complex box RescaleSlopeIntercept_Interface.bbg
[bbtk.git] / packages / itk / src / bbitkImageRegion.h
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbitkImageRegion.h,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:50:39 $
33   Version:   $Revision: 1.8 $
34 =========================================================================*/
35
36
37
38
39 #ifdef _USE_ITK_
40
41 #ifndef __bbitkImageRegion_h_INCLUDED__
42 #define __bbitkImageRegion_h_INCLUDED__
43
44 #include "itkImageRegion.h"
45 #include "bbtkMessageManager.h"
46 #include "bbtkAny.h"
47 #include "bbtkAtomicBlackBox.h"
48
49 namespace bbitk
50 {
51   //=======================================================================
52   /// Type traits ImageRegion to define bbtk::any<ImageRegion>
53   template <typename T> struct ImageRegion { static const bool value = false; };
54   // Specialisations for instantiated image types
55 #ifdef BBTK_ITK_IMAGE_DIM_2
56   typedef itk::ImageRegion<2> ImageRegion_2;
57   template <> struct ImageRegion<ImageRegion_2> { static const bool value = true; };
58 #endif
59 #ifdef BBTK_ITK_IMAGE_DIM_3
60   typedef itk::ImageRegion<3> ImageRegion_3;
61   template <> struct ImageRegion<ImageRegion_3> { static const bool value = true; };
62 #endif
63 #ifdef BBTK_ITK_IMAGE_DIM_4
64   typedef itk::ImageRegion<4> ImageRegion_4;
65   template <> struct ImageRegion<ImageRegion_4> { static const bool value = true; };
66 #endif
67
68   /// 
69   typedef bbtk::any<ImageRegion> anyImageRegion;
70 } // namespace bbitk
71  
72 namespace bbtk
73 {
74   /// Human readable name for bbtk::any<bbitk::ImageRegion>
75   BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::anyImageRegion,"anyItkImageRegion");
76 } // namespace bbtk
77
78
79
80 namespace bbitk
81 {
82   //=======================================================================
83   /// Black Box which creates an anyImageRegion
84   class /*BBTK_EXPORT*/ ImageRegionCreator
85     : public bbtk::AtomicBlackBox
86   {
87     BBTK_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::AtomicBlackBox);
88     BBTK_DECLARE_INPUT(Index,std::vector<long>);
89     BBTK_DECLARE_INPUT(Size,std::vector<long>);
90     BBTK_DECLARE_OUTPUT(Out,anyImageRegion);
91     BBTK_PROCESS(DoIt);
92   private:
93     void DoIt();
94     template <unsigned int Dimension> void DoItForDimension();
95  };
96
97
98   BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageRegionCreator,bbtk::AtomicBlackBox);
99   BBTK_NAME("ImageRegion");
100   BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
101   BBTK_DESCRIPTION("Creates a generic ImageRegion ("+bbtk::TypeName<anyImageRegion>()+") from two vectors providing the index and size of the region. The dimension D of the actual itk::ImageRegion<D> created is the max of the sizes of Index and Size (the smallest vector is padded by zeros).");
102   BBTK_CATEGORY("image");
103         typedef std::vector<long> vectoroflong;
104   BBTK_INPUT(ImageRegionCreator,Index,"Vector of region indices",
105              vectoroflong,"image index");
106   BBTK_INPUT(ImageRegionCreator,Size,"Vector of region sizes",
107              vectoroflong,"image size");
108   BBTK_OUTPUT(ImageRegionCreator,Out,"Output generic region",anyImageRegion,"");
109   BBTK_END_DESCRIBE_BLACK_BOX(ImageRegionCreator);
110   
111 } // namespace bbitk
112
113
114 #endif
115 #endif