(ImagePlus imp)
| 726 | } |
| 727 | |
| 728 | void areaToLine(ImagePlus imp) { |
| 729 | Roi roi = imp.getRoi(); |
| 730 | if (roi==null || !roi.isArea()) { |
| 731 | IJ.error("Area to Line", "Area selection required"); |
| 732 | return; |
| 733 | } |
| 734 | Undo.setup(Undo.ROI, imp); |
| 735 | Polygon p = roi.getPolygon(); |
| 736 | FloatPolygon fp = (roi.subPixelResolution()) ? roi.getFloatPolygon() : null; |
| 737 | if (p==null && fp==null) |
| 738 | return; |
| 739 | int type1 = roi.getType(); |
| 740 | if (type1==Roi.COMPOSITE) { |
| 741 | IJ.error("Area to Line", "Composite selections cannot be converted to lines."); |
| 742 | return; |
| 743 | } |
| 744 | if (fp==null && type1==Roi.TRACED_ROI) { |
| 745 | for (int i=0; i<p.npoints; i++) { |
| 746 | if (p.xpoints[i]>=imp.getWidth()) p.xpoints[i]=imp.getWidth()-1; |
| 747 | if (p.ypoints[i]>=imp.getHeight()) p.ypoints[i]=imp.getHeight()-1; |
| 748 | } |
| 749 | } |
| 750 | int type2 = Roi.POLYLINE; |
| 751 | if (type1==Roi.OVAL||type1==Roi.FREEROI||type1==Roi.TRACED_ROI |
| 752 | ||((roi instanceof PolygonRoi)&&((PolygonRoi)roi).isSplineFit())) |
| 753 | type2 = Roi.FREELINE; |
| 754 | Roi roi2 = fp==null ? new PolygonRoi(p, type2) : new PolygonRoi(fp, type2); |
| 755 | transferProperties(roi, roi2); |
| 756 | Rectangle2D.Double bounds = roi.getFloatBounds(); |
| 757 | roi2.setLocation(bounds.x - 0.5, bounds.y -0.5); //area and line roi coordinates are 0.5 pxl different |
| 758 | imp.setRoi(roi2); |
| 759 | } |
| 760 | |
| 761 | void toBoundingBox(ImagePlus imp) { |
| 762 | Roi roi = imp.getRoi(); |
no test coverage detected