MeVisLab Toolbox Reference
mlClusterInfo.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_CLUSTER_INFO_H
14 #define ML_CLUSTER_INFO_H
15 
17 
18 #include <mlVector3.h>
19 
20 ML_START_NAMESPACE
21 
24 {
26  {
27  useImageValueAsUserData = false;
28  voxelSizeInMilliliters = 0.001;
29  backgroundValue = 0;
30  }
34 };
35 
38 {
40  {
42  max.assign(-ML_DOUBLE_MAX, -ML_DOUBLE_MAX, -ML_DOUBLE_MAX);
43  }
44 
45  void addPosition(MLint x, MLint y, MLint z)
46  {
47  if (min[0] > x) { min[0] = static_cast<MLdouble>(x); }
48  if (min[1] > y) { min[1] = static_cast<MLdouble>(y); }
49  if (min[2] > z) { min[2] = static_cast<MLdouble>(z); }
50 
51  if (max[0] < x) { max[0] = static_cast<MLdouble>(x); }
52  if (max[1] < y) { max[1] = static_cast<MLdouble>(y); }
53  if (max[2] < z) { max[2] = static_cast<MLdouble>(z); }
54  }
55 
58 };
59 
74 {
75 public:
76 
79  _indexId(0),
80  _numVoxels(0),
81  _rank(0),
82  _userData(0),
83  _imageValue(0)
84  {
85  }
86 
89  virtual ~ClusterInfo() {}
90 
92 
94  ML_FORCE_INLINE MLuint getId() const { return _indexId; }
95 
97 
98  ML_FORCE_INLINE MLuint numVoxels() const { return _numVoxels; }
99 
102 
104  ML_FORCE_INLINE MLuint rank() const { return _rank; }
105 
107  ML_FORCE_INLINE MLdouble userData() const { return _userData; }
109  ML_FORCE_INLINE void setUserData(MLdouble userData) { _userData = userData; }
110 
112  ML_FORCE_INLINE MLdouble imageValue() const { return _imageValue; }
114  ML_FORCE_INLINE void setImageValue(MLdouble imageValue) { _imageValue = imageValue; }
115 
117  ML_FORCE_INLINE void addPositionToBoundingBox(MLint x, MLint y, MLint z) { _boundingBox.addPosition(x, y, z); }
119  ML_FORCE_INLINE Vector3 getBoundingBoxMin() const { return _boundingBox.min; }
121  ML_FORCE_INLINE Vector3 getBoundingBoxMax() const { return _boundingBox.max; }
122 
123 
124 protected:
125 
128 
131 
133 
135 
138 
141 
143 };
144 
145 
146 
148 struct less
149 {
155  ML_FORCE_INLINE bool operator() (const ClusterInfo& x, const ClusterInfo& y)
156  {
157  if (x.numVoxels() > y.numVoxels())
158  {
159  return true;
160  }
161  if (x.numVoxels() < y.numVoxels())
162  {
163  return false;
164  }
165  return (x.getId() < y.getId());
166  }
167 };
168 
169 
170 ML_END_NAMESPACE
171 
172 #endif
Holds basic information about a cluster.
Definition: mlClusterInfo.h:74
ML_FORCE_INLINE void setImageValue(MLdouble imageValue)
Sets the image value associated with this cluster.
MLuint _indexId
Unique cluster id; default is 0.
ML_FORCE_INLINE MLuint getId() const
Returns a unique id; default is 0.
Definition: mlClusterInfo.h:94
MLdouble _imageValue
Image value, only meaningful if Identical Intensities is used in the clustering algorithm.
ML_FORCE_INLINE MLuint numVoxels() const
Returns the cluster size in voxel; default is 0.
Definition: mlClusterInfo.h:98
ClusterBoundingBox _boundingBox
ML_FORCE_INLINE Vector3 getBoundingBoxMax() const
Returns the max bounding box position.
ML_FORCE_INLINE void addPositionToBoundingBox(MLint x, MLint y, MLint z)
Adds the given position to this cluster's bounding box.
ML_FORCE_INLINE Vector3 getBoundingBoxMin() const
Returns the min bounding box position.
ML_FORCE_INLINE MLdouble imageValue() const
Returns the image value associated with this cluster.
MLuint _numVoxels
Cluster size in voxel; default is 0.
MLuint _rank
Rank of the cluster size compared to other cluster; default is 0.
ClusterInfo()
Default constructor.
Definition: mlClusterInfo.h:78
ML_FORCE_INLINE void setUserData(MLdouble userData)
Sets the user data.
virtual ~ClusterInfo()
Default destructor.
Definition: mlClusterInfo.h:89
MLdouble _userData
User data, by default its value is set to the rank or original voxel value.
ML_FORCE_INLINE MLdouble userData() const
Returns the user data value.
ML_FORCE_INLINE MLuint rank() const
Returns the rank of the cluster size compared to the other clusters; default is 0.
#define ML_FORCE_INLINE
Forcing the use of 'inline' for methods.
Definition: mlMacros.h:87
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition: mlTypeDefs.h:594
double MLdouble
Definition: mlTypeDefs.h:223
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
#define ML_DOUBLE_MAX
Definition: mlTypeDefs.h:226
Cluster bounding box.
Definition: mlClusterInfo.h:38
void addPosition(MLint x, MLint y, MLint z)
Definition: mlClusterInfo.h:45
Cluster user data parameters.
Definition: mlClusterInfo.h:24
Implement comparison operator for ClusterInfo used by std::sort.