aimsalgo  5.1.2
Neuroimaging image processing
operatormorpho.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef AIMS_MORPHOLOGY_OPERATORMORPHO_H
36 #define AIMS_MORPHOLOGY_OPERATORMORPHO_H
37 
40 
41 using aims::Connectivity;
42 
43 namespace carto
44 {
45  template <typename T> class Volume;
46  template <typename T> class VolumeRef;
47 }
48 
51 {
56 };
57 
58 
62 template <typename T>
64  const carto::rc_ptr<carto::Volume<T> > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D );
65 
66 template <typename T>
68  carto::rc_ptr<carto::Volume<T> > &initvol, float size, Connectivity::Type connectivity );
70 template <typename T>
72  const carto::rc_ptr<carto::Volume<T> > &vol,
73  float size,
74  int xmask=3,
75  int ymask=3,
76  int zmask=3,
77  float mult_fact=50 );
78 
80 template <typename T>
82  const carto::rc_ptr<carto::Volume<T> > &vol, float size, Connectivity::Type type );
83 
84 template <typename T>
86  const carto::rc_ptr<carto::Volume<T> > &initvol, float size, Connectivity::Type connectivity );
87 
89 
90 
94 template <typename T>
96  const carto::rc_ptr<carto::Volume<T> > &vol,
97  float size,
99 
101 template <typename T>
103  const carto::rc_ptr<carto::Volume<T> > &vol,
104  float size,
105  int xmask=3,
106  int ymask=3,
107  int zmask=3,
108  float mult_fact=50 );
109 
111 template <typename T>
113  const carto::rc_ptr<carto::Volume<T> > &vol, float size, Connectivity::Type type);
115 
116 
120 template <typename T>
122  const carto::rc_ptr<carto::Volume<T> > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D );
124 template <typename T>
126  const carto::rc_ptr<carto::Volume<T> > &vol,
127  float size,
128  int xmask=3,
129  int ymask=3,
130  int zmask=3,
131  float mult_fact=50 );
133 template <typename T>
135  const carto::rc_ptr<carto::Volume<T> > &vol, float size, Connectivity::Type type );
137 
138 
142 template <typename T>
144  const carto::rc_ptr<carto::Volume<T> > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D );
146 template <typename T>
148  const carto::rc_ptr<carto::Volume<T> > &vol,
149  float size,
150  int xmask=3,
151  int ymask=3,
152  int zmask=3,
153  float mult_fact=50 );
154 
156 template <typename T>
158  const carto::rc_ptr<carto::Volume<T> > &vol, float size, Connectivity::Type type );
160 
161 namespace aims
162 {
163 
165  template <typename T>
167  {
168  public:
169  MorphoGreyLevel();
170  virtual ~MorphoGreyLevel();
171 
176  bool isChamferBinaryMorphoEnabled() const { return _use_chamfer; }
177  void setChamferBinaryMorphoEnabled( bool x ) { _use_chamfer = x; }
178 
180  doErosion( const carto::VolumeRef<T>& dataIn, float radius );
182  doDilation( const carto::VolumeRef<T>& dataIn, float radius );
184  doClosing( const carto::VolumeRef<T>& dataIn, float radius );
186  doOpening( const carto::VolumeRef<T>& dataIn, float radius );
187 
188  float chamferFactor() const { return _chamfer_factor; }
189  void setChamferFactor( float x ) { _chamfer_factor = x; }
190  Point3d chamferMaskSize() const { return _chamfer_mask_size; }
191  void setChamferMaskSize( const Point3d & p ) { _chamfer_mask_size = p; }
192  int neededBorderWidth() const;
193  static bool isBinary( const carto::VolumeRef<T>& dataIn );
194 
195  private:
196  std::vector<Point3d> doStructElement( float radius,
197  const Point4df & voxelsize );
198  Point3d computeIntRadius( float radius, const Point4df & voxelsize);
199  carto::VolumeRef<T> checkDistanceToBorder(
200  const carto::VolumeRef<T>& dataIn, float radius ) const;
201  carto::VolumeRef<T> checkBorderWidth(
202  const carto::VolumeRef<T>& dataIn ) const;
203  static float distanceToBorder( const carto::VolumeRef<T> &vol );
204  static carto::VolumeRef<T> reallocateVolume(
205  const carto::VolumeRef<T>& dataIn, int added_width, int border_width );
207  tryChamferErosion( const carto::VolumeRef<T>& dataIn, float radius );
209  tryChamferDilation( const carto::VolumeRef<T>& dataIn, float radius );
211  tryChamferClosing( const carto::VolumeRef<T>& dataIn, float radius );
213  tryChamferOpening( const carto::VolumeRef<T>& dataIn, float radius );
214 
215  float radius;
216  Point3d int_radius;
217  std::vector<Point3d> list;
218  bool _use_chamfer;
219  float _chamfer_factor;
220  Point3d _chamfer_mask_size;
221  };
222 
223 }
224 
225 #endif
Grey-level mathematical morphology.
carto::VolumeRef< T > doClosing(const carto::VolumeRef< T > &dataIn, float radius)
float chamferFactor() const
carto::VolumeRef< T > doErosion(const carto::VolumeRef< T > &dataIn, float radius)
void setChamferBinaryMorphoEnabled(bool x)
bool isChamferBinaryMorphoEnabled() const
when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one.
void setChamferMaskSize(const Point3d &p)
static bool isBinary(const carto::VolumeRef< T > &dataIn)
void setChamferFactor(float x)
Point3d chamferMaskSize() const
carto::VolumeRef< T > doDilation(const carto::VolumeRef< T > &dataIn, float radius)
carto::VolumeRef< T > doOpening(const carto::VolumeRef< T > &dataIn, float radius)
carto::VolumeRef< T > AimsMorphoConnectivityChamferOpening(const carto::rc_ptr< carto::Volume< T > > &vol, float size, Connectivity::Type type)
carto::VolumeRef< T > AimsMorphoConnectivityChamferHomotopicErosion(carto::rc_ptr< carto::Volume< T > > &initvol, float size, Connectivity::Type connectivity)
carto::VolumeRef< T > AimsMorphoConnectivityChamferClosing(const carto::rc_ptr< carto::Volume< T > > &vol, float size, Connectivity::Type type)
carto::VolumeRef< T > AimsMorphoDilation(const carto::rc_ptr< carto::Volume< T > > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D)
carto::VolumeRef< T > AimsMorphoConnectivityChamferErosion(const carto::rc_ptr< carto::Volume< T > > &vol, float size, Connectivity::Type type)
carto::VolumeRef< T > AimsMorphoClosing(const carto::rc_ptr< carto::Volume< T > > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D)
AimsMorphoMode
Morphological and chamfer defined modes.
@ AIMS_CHAMFER_BALL_3D
@ AIMS_CHAMFER_BALL_2D
carto::VolumeRef< T > AimsMorphoChamferErosion(const carto::rc_ptr< carto::Volume< T > > &vol, float size, int xmask=3, int ymask=3, int zmask=3, float mult_fact=50)
carto::VolumeRef< T > AimsMorphoOpening(const carto::rc_ptr< carto::Volume< T > > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D)
carto::VolumeRef< T > AimsMorphoChamferDilation(const carto::rc_ptr< carto::Volume< T > > &vol, float size, int xmask=3, int ymask=3, int zmask=3, float mult_fact=50)
carto::VolumeRef< T > AimsMorphoChamferClosing(const carto::rc_ptr< carto::Volume< T > > &vol, float size, int xmask=3, int ymask=3, int zmask=3, float mult_fact=50)
carto::VolumeRef< T > AimsMorphoConnectivityChamferDilation(const carto::rc_ptr< carto::Volume< T > > &vol, float size, Connectivity::Type type)
carto::VolumeRef< T > AimsMorphoErosion(const carto::rc_ptr< carto::Volume< T > > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D)
carto::VolumeRef< T > AimsMorphoChamferOpening(const carto::rc_ptr< carto::Volume< T > > &vol, float size, int xmask=3, int ymask=3, int zmask=3, float mult_fact=50)