11 #ifndef MESH_PROCESS_SEGMENTATION_HPP
12 #define MESH_PROCESS_SEGMENTATION_HPP
35 setName(
"Mesh/Segmentation/Watershed Segmentation");
36 setDesc(
"Propagate labels on mesh using the watershed algorithm.");
37 setIcon(QIcon(
":/images/SegmentMesh.png"));
39 addParm(
"Steps",
"Number of propagation steps performed before updating display. Increase value to run faster.",
"50000");
44 if(!checkState().mesh())
46 return run(currentMesh(), parm(
"Steps").toUInt(), currentMesh()->activeVertices());
49 bool run(
Mesh* mesh,
uint maxsteps,
const std::vector<vertex>& to_segment);
63 setName(
"Mesh/Segmentation/Segmentation Clear");
64 setDesc(
"Clean all mesh labels.");
65 setIcon(QIcon(
":/images/SegmentClear.png"));
70 if(!checkState().mesh())
72 return run(currentMesh());
92 setName(
"Mesh/Segmentation/Relabel");
93 setDesc(
"Relabel a mesh randomly to use consecutive labels.");
94 setIcon(QIcon(
":/images/Relabel.png"));
96 addParm(
"Label Start",
"Starting label.",
"1");
97 addParm(
"Label Step",
"Increment step.",
"1");
103 if(!checkState().mesh(MESH_NON_EMPTY | MESH_LABEL))
105 Mesh* m = currentMesh();
106 int start = parm(
"Label Start").toInt();
107 int step = parm(
"Label Step").toInt();
108 return run(m, start, step);
111 bool run(
Mesh* m,
int start,
int step);
125 setName(
"Mesh/Segmentation/3D Grab Labels");
126 setDesc(
"Grab labels from other mesh (3D meshes).");
127 setIcon(QIcon(
":/images/GrabLabels.png"));
129 addParm(
"Tolerance (µm)",
"Maximal distance between matching cells. ",
"5.0");
134 if(!checkState().mesh(MESH_NON_EMPTY, 0).mesh(MESH_NON_EMPTY, 1))
138 if(currentMesh() == mesh(0)) {
141 }
else if(currentMesh() == mesh(1)) {
147 bool res = run(mesh1, mesh2, parm(
"Tolerance (µm)").toFloat());
151 bool run(
Mesh* mesh1,
Mesh* mesh2,
float tolerance);
165 setName(
"Mesh/Segmentation/Label Selected Vertices");
166 setDesc(
"Label selected vertices with the same value, which can be a new label");
167 setIcon(QIcon(
":/images/LabelSelected.png"));
169 addParm(
"Label",
"Asign this label to all selected vertices.",
"0");
174 if(!checkState().mesh(MESH_LABEL))
176 return run(currentMesh(), parm(
"Label").toInt());
179 bool run(
Mesh* mesh,
int label);
193 setName(
"Mesh/Segmentation/Relabel 3D Cells");
194 setDesc(
"Relabel 3D cells (connected regions). A start label of -1 is used to indicate continuing using current labels.");
195 setIcon(QIcon(
":/images/CellFiles3D.png"));
197 addParm(
"Label start",
"Starting label. Use -1 to continue from last current label.",
"-1");
198 addParm(
"Label step",
"Increment step.",
"1");
203 if(!checkState().mesh(MESH_NON_EMPTY))
205 Mesh* mesh = currentMesh();
206 bool res = run(mesh, parm(
"Label start").toInt(), parm(
"Label step").toInt());
212 bool run(
Mesh* mesh,
int label_start,
int label_step);
226 setName(
"Mesh/Segmentation/Combine Labels");
227 setDesc(
"Combine over-segmented regions, based on mesh signal.");
228 setIcon(QIcon(
":/images/Merge.png"));
230 addParm(
"Border Distance (µm)",
"Half of the cell border width on the mesh.",
"1");
231 addParm(
"Threshold",
"Ratio of border signal over internal signal. If a border between 2 cells has a ratio below the threshold, the cells are fused.",
"1.5");
236 if(!checkState().mesh(MESH_NON_EMPTY))
238 return run(currentMesh(), parm(
"Border Distance (µm)").toFloat(), parm(
"Threshold").toFloat());
241 bool run(
Mesh* mesh,
float borderDist,
float Difference);
256 setName(
"Mesh/Segmentation/Auto Segmentation");
257 setDesc(
"Auto-Segmentation of the mesh surface based on signal. Combines blurring, auto-seeding, label propagation by watershed and fusion of over-segmented cells.");
258 setIcon(QIcon(
":/images/SegmentMesh.png"));
260 addParm(
"Update",
"Option to update mesh drawing while running processes.",
"Yes",booleanChoice());
261 addParm(
"Normalize",
"Option to normalize mesh signal before merging the cells. Most useful in case of low contrast mesh signal.",
"Yes",booleanChoice());
262 addParm(
"Blur Cell Radius (µm)",
"Radius used for gaussian blur of mesh signal. In normal cases, should be equal to auto-seed radius.",
"2.0");
263 addParm(
"Auto-Seed Radius (µm)",
"Radius used for auto-seeding the mesh, based on local minima of signal. Should be equal to radius of smallest cells.",
"2.0");
264 addParm(
"Blur Borders Radius (µm)",
"Radius used for gaussian blur of signal on cell borders before watershed segmentation. Use small values (roughly, half the border width) to avoid border signal distortion.",
"1");
265 addParm(
"Normalization Radius (µm)",
"Radius used for local normalization of signal. Roughly, radius of largest cells.",
"5.0");
266 addParm(
"Border Distance (µm)",
"Half of the cell border width after blurring. Used for fusion of over-segmented cells.",
"1.0");
267 addParm(
"Combine Threshold",
"Ratio of border signal over internal signal. If a borders between 2 cells have a ratio below the threshold, the cells are fused.",
"1.8");
272 if(!checkState().mesh(MESH_NON_EMPTY))
275 parm(
"Blur Cell Radius (µm)").toFloat(), parm(
"Auto-Seed Radius (µm)").toFloat(), parm(
"Blur Borders Radius (µm)").toFloat(), parm(
"Normalization Radius (µm)").toFloat(),
276 parm(
"Border Distance (µm)").toFloat(), parm(
"Combine Threshold").toFloat());
279 bool run(
Mesh* mesh,
bool updateView,
bool normalize,
float gaussianRadiusCell,
280 float localMinimaRadius,
float gaussianRadiusWall,
float normalizeRadius,
float borderDist,