()
| 263 | } |
| 264 | |
| 265 | void fitSpline() { |
| 266 | Roi roi = imp.getRoi(); |
| 267 | if (roi==null) |
| 268 | {noRoi("Spline"); return;} |
| 269 | int type = roi.getType(); |
| 270 | boolean segmentedSelection = type==Roi.POLYGON||type==Roi.POLYLINE; |
| 271 | if (!(segmentedSelection||type==Roi.FREEROI||type==Roi.TRACED_ROI||type==Roi.FREELINE)) |
| 272 | {IJ.error("Spline Fit", "Polygon or polyline selection required"); return;} |
| 273 | if (roi instanceof EllipseRoi) |
| 274 | return; |
| 275 | PolygonRoi p = (PolygonRoi)roi; |
| 276 | p = (PolygonRoi)p.clone(); |
| 277 | Undo.setup(Undo.ROI, imp); |
| 278 | if (!segmentedSelection && p.getNCoordinates()>3) { |
| 279 | if (p.subPixelResolution()) |
| 280 | p = trimFloatPolygon(p, p.getUncalibratedLength()); |
| 281 | else |
| 282 | p = trimPolygon(p, p.getUncalibratedLength()); |
| 283 | } |
| 284 | String options = Macro.getOptions(); |
| 285 | if (options!=null && options.indexOf("straighten")!=-1) |
| 286 | p.fitSplineForStraightening(); |
| 287 | else if (options!=null && options.indexOf("remove")!=-1) |
| 288 | p.removeSplineFit(); |
| 289 | else |
| 290 | p.fitSpline(); |
| 291 | imp.setRoi(p); |
| 292 | imp.draw(); |
| 293 | LineWidthAdjuster.update(); |
| 294 | } |
| 295 | |
| 296 | void interpolate() { |
| 297 | Roi roi = imp.getRoi(); |
no test coverage detected