MorphoGraphX
StackProcessLabels.hpp
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef STACKPROCESSLABELS_HPP
12 #define STACKPROCESSLABELS_HPP
13 
14 #include <Process.hpp>
15 
16 namespace mgx {
17 namespace process {
20 
25 class mgxBase_EXPORT WatershedStack : public StackProcess {
26 public:
28  : Process(process)
29  , StackProcess(process)
30  {
31  }
32 
33  bool operator()(const QStringList&)
34  {
35  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL).store(STORE_WORK | STORE_VISIBLE
36  | STORE_LABEL))
37  return false;
38  Stack* stack = currentStack();
39  Store* main = stack->main();
40  Store* labels = stack->work();
41  return (*this)(stack, main, labels);
42  }
43 
44  bool operator()(Stack* stack, Store* main, Store* labels);
45 
46  QString folder() const {
47  return "Segmentation";
48  }
49  QString name() const {
50  return "Watershed3D";
51  }
52  QString description() const {
53  return "3D Watershed on the current labeled stack.";
54  }
56  return QStringList();
57  }
59  return QStringList();
60  }
61  QIcon icon() const {
62  return QIcon(":/images/SegmentMesh.png");
63  }
64 };
65 
72 class mgxBase_EXPORT ConsolidateRegions : public StackProcess {
73 public:
75  : Process(process)
76  , StackProcess(process)
77  {
78  }
79 
80  bool operator()(const QStringList& parms)
81  {
82  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL).store(STORE_WORK | STORE_VISIBLE
83  | STORE_LABEL))
84  return false;
85  Stack* stack = currentStack();
86  Store* main = stack->main();
87  Store* labels = stack->work();
88  return (*this)(main, labels, parms[0].toUInt(), parms[1].toUInt());
89  }
90 
91  bool operator()(Store* data, Store* labels, uint threshold, uint minvoxels);
92 
93  QString folder() const {
94  return "Segmentation";
95  }
96  QString name() const {
97  return "Consolidate Regions";
98  }
99  QString description() const {
100  return "Consilodate regions after watershed overseeding";
101  }
103  {
104  return QStringList() << "Threshold"
105  << "Min Voxels";
106  }
108  {
109  return QStringList() << "Threshold"
110  << "Min Voxels";
111  }
113  {
114  return QStringList() << "5000"
115  << "100";
116  }
117  QIcon icon() const {
118  return QIcon(":/images/Consolidate.png");
119  }
120 };
121 
127 class mgxBase_EXPORT ConsolidateRegionsNormalized : public StackProcess {
128 public:
130  : Process(process)
131  , StackProcess(process)
132  {
133  }
134 
135  bool operator()(const QStringList& parms)
136  {
137  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL).store(STORE_WORK | STORE_VISIBLE
138  | STORE_LABEL))
139  return false;
140  Stack* stack = currentStack();
141  Store* main = stack->main();
142  Store* labels = stack->work();
143  return (*this)(main, labels, parms[0].toFloat());
144  }
145 
146  bool operator()(Store* data, Store* labels, float tolerance);
147 
148  QString folder() const {
149  return "Segmentation";
150  }
151  QString name() const {
152  return "Consolidate Regions Normalized";
153  }
155  return "Consolidate regions with normalization (slower)";
156  }
158  return QStringList() << "Tolerance";
159  }
161  return QStringList() << "Tolerance";
162  }
164  return QStringList() << "0.3";
165  }
166  QIcon icon() const {
167  return QIcon(":/images/Consolidate.png");
168  }
169 };
170 
176 class mgxBase_EXPORT ThresholdLabelDelete : public StackProcess {
177 public:
179  : Process(process)
180  , StackProcess(process)
181  {
182  }
183 
184  bool operator()(const QStringList& parms)
185  {
186  if(!checkState().store(STORE_LABEL))
187  return false;
188  Stack* stack = currentStack();
189  Store* input = stack->currentStore();
190  Store* output = stack->work();
191  if(!input)
192  return false;
193  bool res = (*this)(input, output, parms[0].toInt(), parms[1].toInt());
194  if(res) {
195  input->hide();
196  output->show();
197  }
198  return res;
199  }
200 
201  bool operator()(const Store* input, Store* labels, uint minVoxels, uint maxVoxels);
202 
203  QString folder() const {
204  return "Segmentation";
205  }
206  QString name() const {
207  return "Delete Labels by Threshold";
208  }
210  return "Delete Labels above/below voxel thresholds";
211  }
213  {
214  return QStringList() << "Min voxels"
215  << "Max voxels";
216  }
218  {
219  return QStringList() << "Min voxels"
220  << "Max voxels";
221  }
223  {
224  return QStringList() << "1000"
225  << "0";
226  }
227  QIcon icon() const {
228  return QIcon(":/images/DeleteLabel.png");
229  }
230 };
231 
240 class mgxBase_EXPORT LocalMaximaStack : public StackProcess {
241 public:
243  : Process(process)
244  , StackProcess(process)
245  {
246  }
247 
248  bool operator()(const QStringList& parms)
249  {
250  if(!checkState().store(STORE_NON_LABEL))
251  return false;
252  Stack* stack = currentStack();
253  Store* input = stack->currentStore();
254  Store* labels = stack->work();
255  if(!input)
256  return false;
257  Point3f radius = Point3u(parms[0].toFloat(), parms[1].toFloat(), parms[2].toFloat());
258  uint lab = parms[3].toUInt();
259  uint minColor = parms[4].toUInt();
260  bool res = (*this)(input, labels, radius, lab, minColor);
261  if(res) {
262  input->hide();
263  labels->show();
264  }
265  return res;
266  }
267 
268  bool operator()(const Store* input, Store* labels, Point3f radius, uint startLabel, uint minColor);
269 
270  QString folder() const {
271  return "Segmentation";
272  }
273  QString name() const {
274  return "Local Maxima";
275  }
277  return "Find local maxima and possibly number them";
278  }
280  {
281  return QStringList() << QString("X Radius (%1)").arg(UM) << QString("Y Radius (%1)").arg(UM)
282  << QString("Z Radius (%1)").arg(UM) << "Start Label"
283  << "Min Color";
284  }
286  {
287  return QStringList() << QString("X Radius (%1)").arg(UM) << QString("Y Radius (%1)").arg(UM)
288  << QString("Z Radius (%1)").arg(UM) << "Start Label"
289  << "Min Color";
290  }
292  {
293  return QStringList() << "5.0"
294  << "5.0"
295  << "5.0"
296  << "2"
297  << "10000";
298  }
299  QIcon icon() const {
300  return QIcon(":/images/LocalMaxima.png");
301  }
302 };
303 
309 class mgxBase_EXPORT FillLabelStack : public StackProcess {
310 public:
312  : Process(process)
313  , StackProcess(process)
314  {
315  }
316 
317  bool operator()(const QStringList& parms)
318  {
319  if(!checkState().store(STORE_LABEL))
320  return false;
321  Stack* stack = currentStack();
322  Store* input = stack->currentStore();
323  Store* output = stack->work();
324  if(!input)
325  return false;
326  bool res = (*this)(input, output, parms[0].toUShort(), parms[1].toUShort());
327  if(res) {
328  input->hide();
329  output->show();
330  }
331  return res;
332  }
333 
334  bool operator()(const Store* input, Store* output, ushort filledLabel, ushort newLabel);
335 
336  QString folder() const {
337  return "Segmentation";
338  }
339  QString name() const {
340  return "Fill Label";
341  }
343  return "Replace a label with another one";
344  }
346  {
347  return QStringList() << "Filled label"
348  << "New label";
349  }
351  {
352  return QStringList() << "Filled label"
353  << "New label";
354  }
356  {
357  return QStringList() << "1000"
358  << "0";
359  }
360  QIcon icon() const {
361  return QIcon(":/images/FillLabel.png");
362  }
363 };
364 
370 class mgxBase_EXPORT EraseAtBorderStack : public StackProcess {
371 public:
373  : Process(process)
374  , StackProcess(process)
375  {
376  }
377 
378  bool operator()(const QStringList&)
379  {
380  if(!checkState().store(STORE_LABEL))
381  return false;
382  Stack* stack = currentStack();
383  Store* input = stack->currentStore();
384  Store* output = stack->work();
385  if(!input)
386  return false;
387  bool res = (*this)(input, output);
388  if(res) {
389  input->hide();
390  output->show();
391  }
392  return res;
393  }
394 
395  bool operator()(const Store* input, Store* output);
396 
397  QString folder() const {
398  return "Segmentation";
399  }
400  QString name() const {
401  return "Erase at Border";
402  }
404  return "Erase any labelled region touching the border of the image";
405  }
407  return QStringList();
408  }
410  return QStringList();
411  }
413  return QStringList();
414  }
415  QIcon icon() const {
416  return QIcon(":/images/EraseLabel.png");
417  }
418 };
420 } // namespace process
421 } // namespace mgx
422 
423 #endif
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:184
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:112
void show()
Ask the user interface to show this store.
Definition: Store.hpp:177
Compute the seeded watershed of the current stack using the CImg library.
Definition: StackProcessLabels.hpp:25
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:406
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:61
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:350
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:157
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:212
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:209
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:203
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:52
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:58
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:248
const Store * currentStore() const
Returns the current store.
Definition: Stack.hpp:122
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:378
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:360
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:339
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:96
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:227
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:117
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:102
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:276
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:80
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:46
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:345
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:160
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:148
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:206
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:273
The Store class holds the actual 3D data and properties specific to it.
Definition: Store.hpp:35
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:403
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:107
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:409
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:33
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:217
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:151
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:279
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:222
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:166
Variation on the ConsolidateRegions process.
Definition: StackProcessLabels.hpp:127
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:412
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:336
File containing the definition of a Process.
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:299
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:135
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:397
Delete labels that have too few or too many voxels.
Definition: StackProcessLabels.hpp:176
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:35
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:99
This is the main process class, the one all process inherit from.
Definition: Process.hpp:258
Try to merge segmented regions based on their contact area and the total voxel intensity at their bou...
Definition: StackProcessLabels.hpp:72
void hide()
Ask the user interface to hide this store.
Definition: Store.hpp:183
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:342
This namespace contains all the classes needed to define processes.
const Store * work() const
Access the work store.
Definition: Stack.hpp:103
QString description() const
Returns a description of the process for the GUI.
Definition: StackProcessLabels.hpp:154
const Store * main() const
Access the main store.
Definition: Stack.hpp:84
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: StackProcessLabels.hpp:415
QStringList parmNames() const
List of named parameters.
Definition: StackProcessLabels.hpp:55
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:163
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:270
Stack processes have non-mutable access to meshes and mutable access to stacks.
Definition: Process.hpp:829
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:49
QStringList parmDescs() const
List of parameters descriptions.
Definition: StackProcessLabels.hpp:285
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:355
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: StackProcessLabels.hpp:317
Erase any label touching the border of the image.
Definition: StackProcessLabels.hpp:370
Find the local maxima of the current image.
Definition: StackProcessLabels.hpp:240
QString name() const
Returns the name of the process.
Definition: StackProcessLabels.hpp:400
Replace one label by another one on the stack.
Definition: StackProcessLabels.hpp:309
QString folder() const
Folder in which to place the process.
Definition: StackProcessLabels.hpp:93
QStringList parmDefaults() const
List of default parms.
Definition: StackProcessLabels.hpp:291