MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeshProcessSegmentation.hpp
1 #ifndef MESH_PROCESS_SEGMENTATION_HPP
2 #define MESH_PROCESS_SEGMENTATION_HPP
3 
4 #include <Process.hpp>
5 
6 class Ui_LoadHeatMap;
7 
8 namespace mgx {
9 namespace process {
12 
20 class mgxBase_EXPORT SegmentMesh : public MeshProcess {
21 public:
22  SegmentMesh(const MeshProcess& process)
23  : Process(process)
24  , MeshProcess(process)
25  {
26  }
27 
28  bool operator()(const QStringList& parms)
29  {
30  if(!checkState().mesh())
31  return false;
32  return (*this)(currentMesh(), parms[0].toUInt(), currentMesh()->activeVertices());
33  }
34 
35  bool operator()(Mesh* mesh, uint maxsteps, const std::vector<vertex>& to_segment);
36 
37  QString folder() const {
38  return "Segmentation";
39  }
40  QString name() const {
41  return "Watershed Segmentation";
42  }
43  QString description() const {
44  return "Propagate labels on mesh using the watershed algorithm.";
45  }
47  return QStringList() << "Steps";
48  }
50  {
51  return QStringList() << "Number of propagation steps performed before updating display. "
52  "Increase value to run faster.";
53  }
55  return QStringList() << "20000";
56  }
57  QIcon icon() const {
58  return QIcon(":/images/SegmentMesh.png");
59  }
60 };
61 
67 class mgxBase_EXPORT SegmentClear : public MeshProcess {
68 public:
69  SegmentClear(const MeshProcess& process)
70  : Process(process)
71  , MeshProcess(process)
72  {
73  }
74 
75  bool operator()(const QStringList&)
76  {
77  if(!checkState().mesh())
78  return false;
79  return (*this)(currentMesh());
80  }
81 
82  bool operator()(Mesh* mesh);
83 
84  QString folder() const {
85  return "Segmentation";
86  }
87  QString name() const {
88  return "Segmentation Clear";
89  }
90  QString description() const {
91  return "Clean all mesh labels.";
92  }
94  return QStringList();
95  }
97  return QStringList();
98  }
99  QIcon icon() const {
100  return QIcon(":/images/SegmentClear.png");
101  }
102 };
103 
112 class mgxBase_EXPORT MeshRelabel : public MeshProcess {
113 public:
114  MeshRelabel(const MeshProcess& process)
115  : Process(process)
116  , MeshProcess(process)
117  {
118  }
119 
120  bool operator()(const QStringList& parms)
121  {
122  if(!checkState().mesh(MESH_NON_EMPTY | MESH_LABEL))
123  return false;
124  Mesh* m = currentMesh();
125  int start = parms[0].toInt();
126  int step = parms[1].toInt();
127  return (*this)(m, start, step);
128  }
129 
130  bool operator()(Mesh* m, int start, int step);
131 
132  QString folder() const {
133  return "Segmentation";
134  }
135  QString name() const {
136  return "Relabel";
137  }
139  return "Relabel a mesh randomly to use consecutive labels.";
140  }
142  {
143  return QStringList() << "Label Start"
144  << "Label Step";
145  }
147  {
148  return QStringList() << "Starting label."
149  << "Increment step.";
150  }
152  {
153  return QStringList() << "1"
154  << "1";
155  }
156  QIcon icon() const {
157  return QIcon(":/images/Relabel.png");
158  }
159 };
160 
166 class mgxBase_EXPORT GrabLabelsSegment : public MeshProcess {
167 public:
168  GrabLabelsSegment(const MeshProcess& process)
169  : Process(process)
170  , MeshProcess(process)
171  {
172  }
173 
174  bool operator()(const QStringList& parms)
175  {
176  if(!checkState().mesh(MESH_NON_EMPTY, 0).mesh(MESH_NON_EMPTY, 1))
177  return false;
178 
179  Mesh* mesh1, *mesh2;
180  if(currentMesh() == mesh(0)) {
181  mesh1 = mesh(0);
182  mesh2 = mesh(1);
183  } else if(currentMesh() == mesh(1)) {
184  mesh2 = mesh(0);
185  mesh1 = mesh(1);
186  } else
187  return false;
188 
189  bool res = (*this)(mesh1, mesh2, parms[0].toFloat());
190  return res;
191  }
192 
193  bool operator()(Mesh* mesh1, Mesh* mesh2, float tolerance);
194 
195  QString name() const {
196  return "3D Grab Labels";
197  }
199  return "Grab labels from other mesh (3D meshes).";
200  }
201  QString folder() const {
202  return "Segmentation";
203  }
205  return QStringList() << QString("Tolerance (%1)").arg(UM);
206  }
208  return QStringList() << "Maximal distance between matching cells. ";
209  }
211  return QStringList() << "5.0";
212  }
213  QIcon icon() const {
214  return QIcon(":/images/GrabLabels.png");
215  }
216 };
217 
223 class mgxBase_EXPORT LabelSelected : public MeshProcess {
224 public:
225  LabelSelected(const MeshProcess& process)
226  : Process(process)
227  , MeshProcess(process)
228  {
229  }
230 
231  bool operator()(const QStringList& parms)
232  {
233  if(!checkState().mesh(MESH_LABEL))
234  return false;
235  return (*this)(currentMesh(), parms[0].toInt());
236  }
237 
238  bool operator()(Mesh* mesh, int label);
239 
240  QString folder() const {
241  return "Segmentation";
242  }
243  QString name() const {
244  return "Label Selected Vertices";
245  }
247  return "Label selected vertices with the same value, which can be a new label";
248  }
250  return QStringList() << "Label";
251  }
253  return QStringList() << "Asign this label to all selected vertices.";
254  }
256  return QStringList() << "0";
257  }
258  QIcon icon() const {
259  return QIcon(":/images/LabelSelected.png");
260  }
261 };
262 
268 class mgxBase_EXPORT RelabelCells3D : public MeshProcess {
269 public:
270  RelabelCells3D(const MeshProcess& process)
271  : Process(process)
272  , MeshProcess(process)
273  {
274  }
275 
276  bool operator()(const QStringList& parms)
277  {
278  if(!checkState().mesh(MESH_NON_EMPTY))
279  return false;
280  Mesh* mesh = currentMesh();
281  bool res = (*this)(mesh, parms[0].toInt(), parms[1].toInt());
282  if(res)
283  mesh->showLabel();
284  return res;
285  }
286 
287  bool operator()(Mesh* mesh, int label_start, int label_step);
288 
289  QString folder() const {
290  return "Segmentation";
291  }
292  QString name() const {
293  return "Relabel 3D Cells";
294  }
296  {
297  return "Relabel 3D cells (connected regions)."
298  " A start label of -1 is used to indicate continuing using current labels.";
299  }
301  {
302  return QStringList() << "Label start"
303  << "Label step";
304  }
306  {
307  return QStringList() << "Starting label. Use -1 to continue from last current label."
308  << "Increment step.";
309  }
311  {
312  return QStringList() << "-1"
313  << "1";
314  }
315  QIcon icon() const {
316  return QIcon(":/images/CellFiles3D.png");
317  }
318 };
319 
326 public:
327  MeshCombineRegions(const MeshProcess& process)
328  : Process(process)
329  , MeshProcess(process)
330  {
331  }
332 
333  bool operator()(const QStringList& parms)
334  {
336  return false;
337  return (*this)(currentMesh(), parms[0].toFloat(), parms[1].toFloat());
338  }
339 
340  bool operator()(Mesh* mesh, float borderDist, float Difference);
341 
342  QString folder() const {
343  return "Segmentation";
344  }
345  QString name() const {
346  return "Combine Labels";
347  }
349  return "Combine over-segmented regions, based on mesh signal.";
350  }
352  return QStringList() << QString("Border Distance (%1)").arg(UM) << "Threshold";
353  }
355  {
356  return QStringList() << "Half of the cell border width on the mesh."
357  << "Ratio of border signal over internal signal. If a border between 2 cells "
358  "has a ratio below the threshold, the cells are fused.";
359  }
361  {
362  return QStringList() << "1"
363  << "1.5";
364  }
365  QIcon icon() const {
366  return QIcon(":/images/Merge.png");
367  }
368 };
369 
376 class MeshAutoSegment : public MeshProcess {
377 public:
378  MeshAutoSegment(const MeshProcess& process)
379  : Process(process)
380  , MeshProcess(process)
381  {
382  }
383 
384  bool operator()(const QStringList& parms)
385  {
387  return false;
388  return (*this)(currentMesh(), stringToBool(parms[0]), stringToBool(parms[1]), parms[2].toFloat(),
389  parms[3].toFloat(), parms[4].toFloat(), parms[5].toFloat(), parms[6].toFloat(),
390  parms[7].toFloat());
391  }
392 
393  bool operator()(Mesh* mesh, bool updateView, bool normalize, float gaussianRadiusCell, float localMinimaRadius,
394  float gaussianRadiusWall, float normalizeRadius, float borderDist, float threshold);
395 
396  QString folder() const {
397  return "Segmentation";
398  }
399  QString name() const {
400  return "Auto-Segmentation";
401  }
403  {
404  return "Auto-Segmentation of the mesh surface based on signal. Combines blurring, auto-seeding, "
405  "label propagation by watershed and fusion of over-segmented cells.";
406  }
408  {
409  return QStringList() << "Update"
410  << "Normalize" << QString("Blur Cell Radius (%1)").arg(UM)
411  << QString("Auto-Seed Radius (%1)").arg(UM) << QString("Blur Borders Radius (%1)").arg(UM)
412  << QString("Normalization Radius (%1)").arg(UM) << QString("Border Distance (%1)").arg(UM)
413  << "Combine Threshold";
414  }
416  {
417  return QStringList()
418  << "Option to update mesh drawing while running processes."
419  << "Option to normalize mesh signal before merging the cells. Most usefull in case of low contrast mesh "
420  "signal."
421  << "Radius used for gaussian blur of mesh signal. In normal cases, should be equal to auto-seed radius."
422  << "Radius used for auto-seeding the mesh, based on local minima of signal. Should be equal to radius "
423  "of smallest cells."
424  << "Radius used for gaussian blur of signal on cell borders before watershed segmentation. Use small "
425  "values (roughly, half the border width) to avoid border signal distortion."
426  << "Radius used for local normalization of signal. Roughly, radius of largest cells."
427  << "Half of the cell border width after blurring. Used for fusion of over-segmented cells."
428  << "Ratio of border signal over internal signal. If a borders between 2 cells have a ratio below the "
429  "threshold, the cells are fused.";
430  }
432  {
433  return QStringList() << "Yes"
434  << "Yes"
435  << "2.0"
436  << "2.0"
437  << "1"
438  << "5.0"
439  << "1.0"
440  << "1.8";
441  }
443  {
444  ParmChoiceMap map;
445  map[0] = booleanChoice();
446  map[1] = booleanChoice();
447  return map;
448  }
449  QIcon icon() const {
450  return QIcon(":/images/SegmentMesh.png");
451  }
452 };
454 } // namespace process
455 } // namespace mgx
456 
457 #endif
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSegmentation.hpp:210
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSegmentation.hpp:300
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSegmentation.hpp:201
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSegmentation.hpp:28
Relabel 3D cells.
Definition: MeshProcessSegmentation.hpp:268
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSegmentation.hpp:54
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSegmentation.hpp:396
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSegmentation.hpp:289
QString name() const
Returns the name of the process.
Definition: MeshProcessSegmentation.hpp:40
arg(const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char( ' ')
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSegmentation.hpp:57
QString name() const
Returns the name of the process.
Definition: MeshProcessSegmentation.hpp:345
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSegmentation.hpp:351
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSegmentation.hpp:151
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSegmentation.hpp:132
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MeshProcessSegmentation.hpp:442
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSegmentation.hpp:90
Process()
Default constructor.
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSegmentation.hpp:342
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSegmentation.hpp:207
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSegmentation.hpp:138
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSegmentation.hpp:431
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSegmentation.hpp:75
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSegmentation.hpp:120
Combine over-segmented regions, based on mesh signal.
Definition: MeshProcessSegmentation.hpp:325
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSegmentation.hpp:240
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSegmentation.hpp:333
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSegmentation.hpp:96
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSegmentation.hpp:174
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSegmentation.hpp:295
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSegmentation.hpp:402
CheckState checkState()
Call this function and convert the result to a boolean.
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSegmentation.hpp:156
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSegmentation.hpp:246
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:167
QString name() const
Returns the name of the process.
Definition: MeshProcessSegmentation.hpp:243
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSegmentation.hpp:198
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSegmentation.hpp:407
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSegmentation.hpp:258
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSegmentation.hpp:315
Segment the mesh using a seeded watershed algorithm.
Definition: MeshProcessSegmentation.hpp:20
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSegmentation.hpp:384
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSegmentation.hpp:354
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSegmentation.hpp:49
Change the label of the selected vertices.
Definition: MeshProcessSegmentation.hpp:223
QString name() const
Returns the name of the process.
Definition: MeshProcessSegmentation.hpp:135
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSegmentation.hpp:213
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSegmentation.hpp:46
File containing the definition of a Process.
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSegmentation.hpp:365
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSegmentation.hpp:231
Mesh * mesh(int i)
Returns the ith mesh.
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSegmentation.hpp:276
Remove any segmentation from the current mesh.
Definition: MeshProcessSegmentation.hpp:67
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSegmentation.hpp:305
This is the main process class, the one all process inherit from.
Definition: Process.hpp:248
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSegmentation.hpp:249
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSegmentation.hpp:99
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSegmentation.hpp:360
Grab labels from other mesh (3D meshes).
Definition: MeshProcessSegmentation.hpp:166
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSegmentation.hpp:93
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
Auto-Segmentation of the mesh surface based on signal.
Definition: MeshProcessSegmentation.hpp:376
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSegmentation.hpp:449
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSegmentation.hpp:37
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSegmentation.hpp:310
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSegmentation.hpp:255
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSegmentation.hpp:146
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSegmentation.hpp:43
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSegmentation.hpp:348
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSegmentation.hpp:141
Non-empty mesh.
Definition: Process.hpp:664
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSegmentation.hpp:84
QStringList booleanChoice() const
Helper function that provides a list of choices for a boolean argument.
Definition: Process.hpp:599
Relabel a segmented mesh.
Definition: MeshProcessSegmentation.hpp:112
Mesh * currentMesh()
Returns the current mesh (i.e.
QString name() const
Returns the name of the process.
Definition: MeshProcessSegmentation.hpp:399
QString name() const
Returns the name of the process.
Definition: MeshProcessSegmentation.hpp:195
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSegmentation.hpp:415
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSegmentation.hpp:204
QString name() const
Returns the name of the process.
Definition: MeshProcessSegmentation.hpp:292
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSegmentation.hpp:252
Mesh processes have mutable access to meshes and non-mutable access to stacks.
Definition: Process.hpp:855
QString name() const
Returns the name of the process.
Definition: MeshProcessSegmentation.hpp:87