MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / areaToLine

Method areaToLine

ij/src/main/java/ij/plugin/Selection.java:728–759  ·  view source on GitHub ↗
(ImagePlus imp)

Source from the content-addressed store, hash-verified

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();

Callers 1

runMethod · 0.95

Calls 15

isAreaMethod · 0.95
errorMethod · 0.95
setupMethod · 0.95
getPolygonMethod · 0.95
subPixelResolutionMethod · 0.95
getFloatPolygonMethod · 0.95
getTypeMethod · 0.95
transferPropertiesMethod · 0.95
getFloatBoundsMethod · 0.95
setLocationMethod · 0.95
getRoiMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected