MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StackProcessLabels.hpp
1 #ifndef STACKPROCESSLABELS_HPP
2 #define STACKPROCESSLABELS_HPP
3 
4 #include <Process.hpp>
5 
6 namespace mgx {
7 namespace process {
10 
15 class mgxBase_EXPORT WatershedStack : public StackProcess {
16 public:
17  WatershedStack(const StackProcess& process)
18  : Process(process)
19  , StackProcess(process)
20  {
21  }
22 
23  bool operator()(const QStringList&)
24  {
25  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL).store(STORE_WORK | STORE_VISIBLE
26  | STORE_LABEL))
27  return false;
28  Stack* stack = currentStack();
29  Store* main = stack->main();
30  Store* labels = stack->work();
31  return (*this)(stack, main, labels);
32  }
33 
34  bool operator()(Stack* stack, Store* main, Store* labels);
35 
36  QString folder() const {
37  return "Segmentation";
38  }
39  QString name() const {
40  return "Watershed3D";
41  }
42  QString description() const {
43  return "3D Watershed on the current labeled stack.";
44  }
46  return QStringList();
47  }
49  return QStringList();
50  }
51  QIcon icon() const {
52  return QIcon(":/images/SegmentMesh.png");
53  }
54 };
55 
62 class mgxBase_EXPORT ConsolidateRegions : public StackProcess {
63 public:
64  ConsolidateRegions(const StackProcess& process)
65  : Process(process)
66  , StackProcess(process)
67  {
68  }
69 
70  bool operator()(const QStringList& parms)
71  {
72  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL).store(STORE_WORK | STORE_VISIBLE
73  | STORE_LABEL))
74  return false;
75  Stack* stack = currentStack();
76  Store* main = stack->main();
77  Store* labels = stack->work();
78  return (*this)(main, labels, parms[0].toUInt(), parms[1].toUInt());
79  }
80 
81  bool operator()(Store* data, Store* labels, uint threshold, uint minvoxels);
82 
83  QString folder() const {
84  return "Segmentation";
85  }
86  QString name() const {
87  return "Consolidate Regions";
88  }
89  QString description() const {
90  return "Consilodate regions after watershed overseeding";
91  }
93  {
94  return QStringList() << "Threshold"
95  << "Min Voxels";
96  }
98  {
99  return QStringList() << "Threshold"
100  << "Min Voxels";
101  }
103  {
104  return QStringList() << "5000"
105  << "100";
106  }
107  QIcon icon() const {
108  return QIcon(":/images/Consolidate.png");
109  }
110 };
111 
117 class mgxBase_EXPORT ConsolidateRegionsNormalized : public StackProcess {
118 public:
120  : Process(process)
121  , StackProcess(process)
122  {
123  }
124 
125  bool operator()(const QStringList& parms)
126  {
127  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL).store(STORE_WORK | STORE_VISIBLE
128  | STORE_LABEL))
129  return false;
130  Stack* stack = currentStack();
131  Store* main = stack->main();
132  Store* labels = stack->work();
133  return (*this)(main, labels, parms[0].toFloat());
134  }
135 
136  bool operator()(Store* data, Store* labels, float tolerance);
137 
138  QString folder() const {
139  return "Segmentation";
140  }
141  QString name() const {
142  return "Consolidate Regions Normalized";
143  }
145  return "Consolidate regions with normalization (slower)";
146  }
148  return QStringList() << "Tolerance";
149  }
151  return QStringList() << "Tolerance";
152  }
154  return QStringList() << "0.3";
155  }
156  QIcon icon() const {
157  return QIcon(":/images/Consolidate.png");
158  }
159 };
160 
166 class mgxBase_EXPORT ThresholdLabelDelete : public StackProcess {
167 public:
168  ThresholdLabelDelete(const StackProcess& process)
169  : Process(process)
170  , StackProcess(process)
171  {
172  }
173 
174  bool operator()(const QStringList& parms)
175  {
176  if(!checkState().store(STORE_LABEL))
177  return false;
178  Stack* stack = currentStack();
179  Store* input = stack->currentStore();
180  Store* output = stack->work();
181  if(!input)
182  return false;
183  bool res = (*this)(input, output, parms[0].toInt(), parms[1].toInt());
184  if(res) {
185  input->hide();
186  output->show();
187  }
188  return res;
189  }
190 
191  bool operator()(const Store* input, Store* labels, uint minVoxels, uint maxVoxels);
192 
193  QString folder() const {
194  return "Segmentation";
195  }
196  QString name() const {
197  return "Delete Labels by Threshold";
198  }
200  return "Delete Labels above/below voxel thresholds";
201  }
203  {
204  return QStringList() << "Min voxels"
205  << "Max voxels";
206  }
208  {
209  return QStringList() << "Min voxels"
210  << "Max voxels";
211  }
213  {
214  return QStringList() << "1000"
215  << "0";
216  }
217  QIcon icon() const {
218  return QIcon(":/images/DeleteLabel.png");
219  }
220 };
221 
230 class mgxBase_EXPORT LocalMaximaStack : public StackProcess {
231 public:
232  LocalMaximaStack(const StackProcess& process)
233  : Process(process)
234  , StackProcess(process)
235  {
236  }
237 
238  bool operator()(const QStringList& parms)
239  {
240  if(!checkState().store(STORE_NON_LABEL))
241  return false;
242  Stack* stack = currentStack();
243  Store* input = stack->currentStore();
244  Store* labels = stack->work();
245  if(!input)
246  return false;
247  Point3f radius = Point3u(parms[0].toFloat(), parms[1].toFloat(), parms[2].toFloat());
248  uint lab = parms[3].toUInt();
249  uint minColor = parms[4].toUInt();
250  bool res = (*this)(input, labels, radius, lab, minColor);
251  if(res) {
252  input->hide();
253  labels->show();
254  }
255  return res;
256  }
257 
258  bool operator()(const Store* input, Store* labels, Point3f radius, uint startLabel, uint minColor);
259 
260  QString folder() const {
261  return "Segmentation";
262  }
263  QString name() const {
264  return "Local Maxima";
265  }
267  return "Find local maxima and possibly number them";
268  }
270  {
271  return QStringList() << QString("X Radius (%1)").arg(UM) << QString("Y Radius (%1)").arg(UM)
272  << QString("Z Radius (%1)").arg(UM) << "Start Label"
273  << "Min Color";
274  }
276  {
277  return QStringList() << QString("X Radius (%1)").arg(UM) << QString("Y Radius (%1)").arg(UM)
278  << QString("Z Radius (%1)").arg(UM) << "Start Label"
279  << "Min Color";
280  }
282  {
283  return QStringList() << "5.0"
284  << "5.0"
285  << "5.0"
286  << "2"
287  << "10000";
288  }
289  QIcon icon() const {
290  return QIcon(":/images/LocalMaxima.png");
291  }
292 };
293 
299 class mgxBase_EXPORT FillLabelStack : public StackProcess {
300 public:
301  FillLabelStack(const StackProcess& process)
302  : Process(process)
303  , StackProcess(process)
304  {
305  }
306 
307  bool operator()(const QStringList& parms)
308  {
309  if(!checkState().store(STORE_LABEL))
310  return false;
311  Stack* stack = currentStack();
312  Store* input = stack->currentStore();
313  Store* output = stack->work();
314  if(!input)
315  return false;
316  bool res = (*this)(input, output, parms[0].toUShort(), parms[1].toUShort());
317  if(res) {
318  input->hide();
319  output->show();
320  }
321  return res;
322  }
323 
324  bool operator()(const Store* input, Store* output, ushort filledLabel, ushort newLabel);
325 
326  QString folder() const {
327  return "Segmentation";
328  }
329  QString name() const {
330  return "Fill Label";
331  }
333  return "Replace a label with another one";
334  }
336  {
337  return QStringList() << "Filled label"
338  << "New label";
339  }
341  {
342  return QStringList() << "Filled label"
343  << "New label";
344  }
346  {
347  return QStringList() << "1000"
348  << "0";
349  }
350  QIcon icon() const {
351  return QIcon(":/images/FillLabel.png");
352  }
353 };
354 
360 class mgxBase_EXPORT EraseAtBorderStack : public StackProcess {
361 public:
362  EraseAtBorderStack(const StackProcess& process)
363  : Process(process)
364  , StackProcess(process)
365  {
366  }
367 
368  bool operator()(const QStringList&)
369  {
370  if(!checkState().store(STORE_LABEL))
371  return false;
372  Stack* stack = currentStack();
373  Store* input = stack->currentStore();
374  Store* output = stack->work();
375  if(!input)
376  return false;
377  bool res = (*this)(input, output);
378  if(res) {
379  input->hide();
380  output->show();
381  }
382  return res;
383  }
384 
385  bool operator()(const Store* input, Store* output);
386 
387  QString folder() const {
388  return "Segmentation";
389  }
390  QString name() const {
391  return "Erase at Border";
392  }
394  return "Erase any labelled region touching the border of the image";
395  }
397  return QStringList();
398  }
400  return QStringList();
401  }
403  return QStringList();
404  }
405  QIcon icon() const {
406  return QIcon(":/images/EraseLabel.png");
407  }
408 };
410 } // namespace process
411 } // namespace mgx
412 
413 #endif
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:174
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:102
void show()
Ask the user interface to show this store.
Definition: Store.hpp:167
Compute the seeded watershed of the current stack using the CImg library.
Definition: StackProcessLabels.hpp:15
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:396
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:51
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:340
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:147
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:202
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:199
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:193
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:42
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:48
arg(const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char( ' ')
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:238
const Store * currentStore() const
Returns the current store.
Definition: Stack.hpp:112
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:368
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:350
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:329
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:86
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:217
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:107
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:92
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:266
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:70
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:36
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:335
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:150
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:138
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:196
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:263
The Store class holds the actual 3D data and properties specific to it.
Definition: Store.hpp:25
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:393
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:97
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:399
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:23
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:207
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:141
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:269
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:212
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:156
Variation on the ConsolidateRegions process.
Definition: StackProcessLabels.hpp:117
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:402
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:326
File containing the definition of a Process.
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:289
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:125
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:387
Delete labels that have too few or too many voxels.
Definition: StackProcessLabels.hpp:166
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:25
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:89
This is the main process class, the one all process inherit from.
Definition: Process.hpp:248
Try to merge segmented regions based on their contact area and the total voxel intensity at their bou...
Definition: StackProcessLabels.hpp:62
void hide()
Ask the user interface to hide this store.
Definition: Store.hpp:173
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:332
const Store * work() const
Access the work store.
Definition: Stack.hpp:93
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:144
const Store * main() const
Access the main store.
Definition: Stack.hpp:74
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:405
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:45
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:153
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:260
Stack processes have non-mutable access to meshes and mutable access to stacks.
Definition: Process.hpp:819
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:39
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:275
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:345
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:307
Erase any label touching the border of the image.
Definition: StackProcessLabels.hpp:360
Find the local maxima of the current image.
Definition: StackProcessLabels.hpp:230
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:390
Replace one label by another one on the stack.
Definition: StackProcessLabels.hpp:299
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:83
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:281