aimsalgo  5.0.5
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 template <typename T> class AimsData;
44 namespace carto
45 {
46  template <typename T> class Volume;
47  template <typename T> class VolumeRef;
48 }
49 
52 {
57 };
58 
59 
64 template <typename T>
66  const AimsData<T> &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D );
67 
69 template <typename T>
71  AimsData<T> &initvol, float size, Connectivity::Type connectivity );
74 template <typename T>
76  const AimsData<T> &vol,
77  float size,
78  int xmask=3,
79  int ymask=3,
80  int zmask=3,
81  float mult_fact=50 );
82 
85 template <typename T>
87  const AimsData<T> &vol, float size, Connectivity::Type type );
88 
90 template <typename T>
92  const AimsData<T> &initvol, float size, Connectivity::Type connectivity );
93 
95 
96 
101 template <typename T>
103  const AimsData<T> &vol,
104  float size,
106 
109 template <typename T>
111  const AimsData<T> &vol,
112  float size,
113  int xmask=3,
114  int ymask=3,
115  int zmask=3,
116  float mult_fact=50 );
117 
120 template <typename T>
122  const AimsData<T> &vol, float size, Connectivity::Type type);
124 
125 
130 template <typename T>
132  const AimsData<T> &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D );
135 template <typename T>
137  const AimsData<T> &vol,
138  float size,
139  int xmask=3,
140  int ymask=3,
141  int zmask=3,
142  float mult_fact=50 );
145 template <typename T>
147  const AimsData<T> &vol, float size, Connectivity::Type type );
149 
150 
155 template <typename T>
157  const AimsData<T> &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D );
160 template <typename T>
162  const AimsData<T> &vol,
163  float size,
164  int xmask=3,
165  int ymask=3,
166  int zmask=3,
167  float mult_fact=50 );
168 
171 template <typename T>
173  const AimsData<T> &vol, float size, Connectivity::Type type );
175 
176 namespace aims
177 {
178 
180  template <typename T>
182  {
183  public:
184  MorphoGreyLevel();
185  virtual ~MorphoGreyLevel();
186 
191  bool isChamferBinaryMorphoEnabled() const { return _use_chamfer; }
192  void setChamferBinaryMorphoEnabled( bool x ) { _use_chamfer = x; }
193 
195  doErosion( const carto::VolumeRef<T>& dataIn, float radius );
197  doDilation( const carto::VolumeRef<T>& dataIn, float radius );
199  doClosing( const carto::VolumeRef<T>& dataIn, float radius );
201  doOpening( const carto::VolumeRef<T>& dataIn, float radius );
202 
203  float chamferFactor() const { return _chamfer_factor; }
204  void setChamferFactor( float x ) { _chamfer_factor = x; }
205  Point3d chamferMaskSize() const { return _chamfer_mask_size; }
206  void setChamferMaskSize( const Point3d & p ) { _chamfer_mask_size = p; }
207  int neededBorderWidth() const;
208  static bool isBinary( const carto::VolumeRef<T>& dataIn );
209 
210  private:
211  std::vector<Point3d> doStructElement( float radius,
212  const Point4df & voxelsize );
213  Point3d computeIntRadius( float radius, const Point4df & voxelsize);
214  carto::VolumeRef<T> checkDistanceToBorder(
215  const carto::VolumeRef<T>& dataIn, float radius ) const;
216  carto::VolumeRef<T> checkBorderWidth(
217  const carto::VolumeRef<T>& dataIn ) const;
218  static float distanceToBorder( const carto::VolumeRef<T> &vol );
219  static carto::VolumeRef<T> reallocateVolume(
220  const carto::VolumeRef<T>& dataIn, int added_width, int border_width );
222  tryChamferErosion( const carto::VolumeRef<T>& dataIn, float radius );
224  tryChamferDilation( const carto::VolumeRef<T>& dataIn, float radius );
226  tryChamferClosing( const carto::VolumeRef<T>& dataIn, float radius );
228  tryChamferOpening( const carto::VolumeRef<T>& dataIn, float radius );
229 
230  float radius;
231  Point3d int_radius;
232  std::vector<Point3d> list;
233  bool _use_chamfer;
234  float _chamfer_factor;
235  Point3d _chamfer_mask_size;
236  };
237 
238 }
239 
240 #endif
bool isChamferBinaryMorphoEnabled() const
when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one...
AIMSALGO_API AimsData< T > AimsMorphoChamferDilation(const AimsData< T > &vol, float size, int xmask=3, int ymask=3, int zmask=3, float mult_fact=50)
AIMSALGO_API AimsData< T > AimsMorphoConnectivityChamferErosion(const AimsData< T > &vol, float size, Connectivity::Type type)
float chamferFactor() const
AIMSALGO_API AimsData< T > AimsMorphoChamferClosing(const AimsData< T > &vol, float size, int xmask=3, int ymask=3, int zmask=3, float mult_fact=50)
AIMSALGO_API AimsData< T > AimsMorphoClosing(const AimsData< T > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D)
AIMSALGO_API AimsData< T > AimsMorphoErosion(const AimsData< T > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D)
AIMSALGO_API AimsData< T > AimsMorphoDilation(const AimsData< T > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D)
AIMSALGO_API AimsData< T > AimsMorphoConnectivityChamferOpening(const AimsData< T > &vol, float size, Connectivity::Type type)
void setChamferBinaryMorphoEnabled(bool x)
AimsMorphoMode
Morphological and chamfer defined modes.
AIMSALGO_API AimsData< T > AimsMorphoConnectivityChamferHomotopicErosion(AimsData< T > &initvol, float size, Connectivity::Type connectivity)
AIMSALGO_API AimsData< T > AimsMorphoConnectivityChamferDilation(const AimsData< T > &vol, float size, Connectivity::Type type)
AIMSALGO_API AimsData< T > AimsMorphoChamferErosion(const AimsData< T > &vol, float size, int xmask=3, int ymask=3, int zmask=3, float mult_fact=50)
Point3d chamferMaskSize() const
void setChamferMaskSize(const Point3d &p)
AIMSALGO_API AimsData< T > AimsMorphoChamferOpening(const AimsData< T > &vol, float size, int xmask=3, int ymask=3, int zmask=3, float mult_fact=50)
#define AIMSALGO_API
AIMSALGO_API AimsData< T > AimsMorphoConnectivityChamferClosing(const AimsData< T > &vol, float size, Connectivity::Type type)
Grey-level mathematical morphology.
AIMSALGO_API AimsData< T > AimsMorphoOpening(const AimsData< T > &vol, float size, AimsMorphoMode mode=AIMS_CHAMFER_BALL_3D)
void setChamferFactor(float x)