MorphoGraphX  2.0-1-227
StackProcessLabels.hpp
Go to the documentation of this file.
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 {
20 
25  class mgxBase_EXPORT WatershedStack : public Process
26  {
27  public:
28  WatershedStack(const Process& process) : Process(process)
29  {
30  setName("Stack/Segmentation/Watershed3D");
31  setDesc("3D Watershed on the current labeled stack.");
32  setIcon(QIcon(":/images/SegmentMesh.png"));
33  }
34 
35  bool run()
36  {
37  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL)
38  .store(STORE_WORK | STORE_VISIBLE | STORE_LABEL))
39  return false;
40  Stack* stack = currentStack();
41  Store* main = stack->main();
42  Store* labels = stack->work();
43  return run(stack, main, labels);
44  }
45 
46  bool run(Stack* stack, Store* main, Store* labels);
47  };
48 
55  class mgxBase_EXPORT ConsolidateRegions : public Process
56  {
57  public:
58  ConsolidateRegions(const Process& process) : Process(process)
59  {
60 
61  setName("Stack/Segmentation/Consolidate Regions");
62  setDesc("Consilodate regions after watershed overseeding");
63  setIcon(QIcon(":/images/Consolidate.png"));
64 
65  addParm("Threshold","Threshold","5000");
66  addParm("Min Voxels","Min Voxels","100");
67  }
68 
69  bool run()
70  {
71  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL)
72  .store(STORE_WORK | STORE_VISIBLE | STORE_LABEL))
73  return false;
74  Stack* stack = currentStack();
75  Store* main = stack->main();
76  Store* labels = stack->work();
77  return run(main, labels, parm("Threshold").toUInt(), parm("Min Voxels").toUInt());
78  }
79 
80  bool run(Store* data, Store* labels, uint threshold, uint minvoxels);
81 
82  };
83 
89  class mgxBase_EXPORT ConsolidateRegionsNormalized : public Process
90  {
91  public:
92  ConsolidateRegionsNormalized(const Process& process) : Process(process)
93  {
94  setName("Stack/Segmentation/Consolidate Regions Normalized");
95  setDesc("Consolidate regions with normalization (slower)");
96  setIcon(QIcon(":/images/Consolidate.png"));
97 
98  addParm("Tolerance","Tolerance","0.3");
99  }
100 
101  bool run()
102  {
103  if(!checkState().store(STORE_MAIN | STORE_VISIBLE | STORE_NON_LABEL)
104  .store(STORE_WORK | STORE_VISIBLE | STORE_LABEL))
105  return false;
106  Stack* stack = currentStack();
107  Store* main = stack->main();
108  Store* labels = stack->work();
109  return run(main, labels, parm("Tolerance").toFloat());
110  }
111 
112  bool run(Store* data, Store* labels, float tolerance);
113 
114  };
115 
121  class mgxBase_EXPORT ThresholdLabelDelete : public Process
122  {
123  public:
124  ThresholdLabelDelete(const Process& process) : Process(process)
125  {
126 
127  setName("Stack/Segmentation/Delete Labels by Threshold");
128  setDesc("Delete Labels above/below voxel thresholds");
129  setIcon(QIcon(":/images/DeleteLabel.png"));
130 
131  addParm("Min voxels","Min voxels","1000");
132  addParm("Max voxels","Max voxels","0");
133  }
134 
135  bool run()
136  {
137  if(!checkState().store(STORE_LABEL))
138  return false;
139  Stack* stack = currentStack();
140  Store* input = stack->currentStore();
141  Store* output = stack->work();
142  if(!input)
143  return false;
144  bool res = run(input, output, parm("Min voxels").toInt(), parm("Max voxels").toInt());
145  if(res) {
146  input->hide();
147  output->show();
148  }
149  return res;
150  }
151 
152  bool run(const Store* input, Store* labels, uint minVoxels, uint maxVoxels);
153  };
154 
163  class mgxBase_EXPORT LocalMaximaStack : public Process
164  {
165  public:
166  LocalMaximaStack(const Process& process) : Process(process)
167  {
168  setName("Stack/Segmentation/Local Maxima");
169  setDesc("Find local maxima and possibly number them");
170  setIcon(QIcon(":/images/LocalMaxima.png"));
171 
172  addParm("X Radius","X Radius (µm)","5.0");
173  addParm("Y Radius","Y Radius (µm)","5.0");
174  addParm("Z Radius","Z Radius (µm)","5.0");
175  addParm("Start Label","Start Label","2");
176  addParm("Threshold", "Only consider voxel values larger than this value as maxima", "10000");
177  addParm("Value", "Value to set voxel if not labeling", "60000");
178  }
179 
180  bool run()
181  {
182  if(!checkState().store(STORE_NON_LABEL))
183  return false;
184  Stack* stack = currentStack();
185  Store* input = stack->currentStore();
186  Store* output = stack->work();
187  if(!input)
188  return false;
189  Point3f radius(parm("X Radius").toFloat(), parm("Y Radius").toFloat(), parm("Z Radius").toFloat());
190  uint label = parm("Start Label").toUInt();
191  uint threshold = parm("Threshold").toUInt();
192  uint value = parm("Value").toUInt();
193  bool res = run(input, output, radius, label, threshold, value);
194  if(res) {
195  input->hide();
196  output->show();
197  }
198  return res;
199  }
200 
201  bool run(const Store* input, Store* labels, Point3f radius, uint startLabel, uint threshold, uint value);
202  };
203 
209  class mgxBase_EXPORT FillLabelStack : public Process
210  {
211  public:
212  FillLabelStack(const Process& process) : Process(process)
213  {
214  setName("Stack/Segmentation/Fill Label");
215  setDesc("Replace a label with another one");
216  setIcon(QIcon(":/images/FillLabel.png"));
217 
218  addParm("Filled label","Filled label","1000");
219  addParm("New label","New label","0");
220  }
221 
222  bool run()
223  {
224  if(!checkState().store(STORE_LABEL))
225  return false;
226  Stack* stack = currentStack();
227  Store* input = stack->currentStore();
228  Store* output = stack->work();
229  if(!input)
230  return false;
231  bool res = run(input, output, parm("Filled label").toUShort(), parm("New label").toUShort());
232  if(res) {
233  input->hide();
234  output->show();
235  }
236  return res;
237  }
238 
239  bool run(const Store* input, Store* output, ushort filledLabel, ushort newLabel);
240 
241  };
242 
248  class mgxBase_EXPORT EraseAtBorderStack : public Process
249  {
250  public:
251  EraseAtBorderStack(const Process& process) : Process(process)
252  {
253  setName("Stack/Segmentation/Erase at Border");
254  setDesc("Erase any labelled region touching the border of the image");
255  setIcon(QIcon(":/images/EraseLabel.png"));
256  }
257 
258  bool run()
259  {
260  if(!checkState().store(STORE_LABEL))
261  return false;
262  Stack* stack = currentStack();
263  Store* input = stack->currentStore();
264  Store* output = stack->work();
265  if(!input)
266  return false;
267  bool res = run(input, output);
268  if(res) {
269  input->hide();
270  output->show();
271  }
272  return res;
273  }
274 
275  bool run(const Store* input, Store* output);
276 
277  };
278 
279 
285  class mgxBase_EXPORT StackExportByLabel : public Process
286  {
287  public:
288  StackExportByLabel(const Process& process) : Process(process)
289  {
290  setName("Stack/Segmentation/Export by Label");
291  setDesc(" Export stack to individual files, one per label");
292 
293  addParm("File Prefix","Prefix for file name","Cell"); // 0
294  }
295 
296  //bool initialize(QStringList& parms, QWidget* parent);
297 
298  bool run();
299 
300  };
302 }
303 
304 #endif
mgx::ThresholdLabelDelete::ThresholdLabelDelete
ThresholdLabelDelete(const Process &process)
Definition: StackProcessLabels.hpp:124
mgx::StackExportByLabel
Definition: StackProcessLabels.hpp:285
mgx::uint
unsigned int uint
Definition: Geometry.hpp:41
mgx::WatershedStack::run
bool run()
Runs the process.
Definition: StackProcessLabels.hpp:35
Process.hpp
mgx::EraseAtBorderStack
Definition: StackProcessLabels.hpp:248
mgx::FillLabelStack
Definition: StackProcessLabels.hpp:209
mgx::ConsolidateRegions
Definition: StackProcessLabels.hpp:55
mgx::LocalMaximaStack
Definition: StackProcessLabels.hpp:163
mgx::ConsolidateRegions::run
bool run()
Runs the process.
Definition: StackProcessLabels.hpp:69
mgx::Stack::work
const Store * work() const
Access the work store.
Definition: Stack.hpp:101
mgx::FillLabelStack::FillLabelStack
FillLabelStack(const Process &process)
Definition: StackProcessLabels.hpp:212
mgx::Stack::currentStore
const Store * currentStore() const
Returns the current store.
Definition: Stack.hpp:120
mgx::ConsolidateRegionsNormalized::ConsolidateRegionsNormalized
ConsolidateRegionsNormalized(const Process &process)
Definition: StackProcessLabels.hpp:92
mgx::ushort
unsigned short ushort
Simpler names for the various containers and iterators.
Definition: Geometry.hpp:42
mgx::Stack::main
const Store * main() const
Access the main store.
Definition: Stack.hpp:82
mgx::LocalMaximaStack::LocalMaximaStack
LocalMaximaStack(const Process &process)
Definition: StackProcessLabels.hpp:166
mgx::FillLabelStack::run
bool run()
Runs the process.
Definition: StackProcessLabels.hpp:222
mgx::Stack
Definition: Stack.hpp:33
mgx::ThresholdLabelDelete::run
bool run()
Runs the process.
Definition: StackProcessLabels.hpp:135
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::Store::hide
void hide()
Ask the user interface to hide this store.
Definition: Store.hpp:167
mgx::ConsolidateRegionsNormalized
Definition: StackProcessLabels.hpp:89
mgx::Process
Definition: Process.hpp:219
mgx::LocalMaximaStack::run
bool run()
Runs the process.
Definition: StackProcessLabels.hpp:180
mgx::Store::show
void show()
Ask the user interface to show this store.
Definition: Store.hpp:162
mgx::StackExportByLabel::StackExportByLabel
StackExportByLabel(const Process &process)
Definition: StackProcessLabels.hpp:288
mgx::Vector< 3, float >
mgx::EraseAtBorderStack::EraseAtBorderStack
EraseAtBorderStack(const Process &process)
Definition: StackProcessLabels.hpp:251
mgx::WatershedStack::WatershedStack
WatershedStack(const Process &process)
Definition: StackProcessLabels.hpp:28
mgx::EraseAtBorderStack::run
bool run()
Runs the process.
Definition: StackProcessLabels.hpp:258
mgx::WatershedStack
Definition: StackProcessLabels.hpp:25
mgx::ConsolidateRegionsNormalized::run
bool run()
Runs the process.
Definition: StackProcessLabels.hpp:101
mgx::ThresholdLabelDelete
Definition: StackProcessLabels.hpp:121
mgx::ConsolidateRegions::ConsolidateRegions
ConsolidateRegions(const Process &process)
Definition: StackProcessLabels.hpp:58
mgx::Store
Definition: Store.hpp:33