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

Method createEllipse

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

Source from the content-addressed store, hash-verified

545 }
546
547 void createEllipse(ImagePlus imp) {
548 if (!imp.okToDeleteRoi()) return;
549 IJ.showStatus("Fitting ellipse");
550 Roi roi = imp.getRoi();
551 if (roi==null)
552 {noRoi("Fit Ellipse"); return;}
553 if (roi.isLine())
554 {IJ.error("Fit Ellipse", "\"Fit Ellipse\" does not work with line selections"); return;}
555 ImageProcessor ip = imp.getProcessor();
556 ip.setRoi(roi);
557 int options = Measurements.CENTROID+Measurements.ELLIPSE;
558 ImageStatistics stats = ImageStatistics.getStatistics(ip, options, null);
559 double dx = stats.major*Math.cos(stats.angle/180.0*Math.PI)/2.0;
560 double dy = - stats.major*Math.sin(stats.angle/180.0*Math.PI)/2.0;
561 double x1 = stats.xCentroid - dx;
562 double x2 = stats.xCentroid + dx;
563 double y1 = stats.yCentroid - dy;
564 double y2 = stats.yCentroid + dy;
565 double aspectRatio = stats.minor/stats.major;
566 Undo.setup(Undo.ROI, imp);
567 imp.deleteRoi();
568 Roi roi2 = new EllipseRoi(x1,y1,x2,y2,aspectRatio);
569 transferProperties(roi, roi2);
570 imp.setRoi(roi2);
571 }
572
573 void convexHull(ImagePlus imp) {
574 if (!imp.okToDeleteRoi()) return;

Callers 1

runMethod · 0.95

Calls 13

showStatusMethod · 0.95
noRoiMethod · 0.95
isLineMethod · 0.95
errorMethod · 0.95
setRoiMethod · 0.95
getStatisticsMethod · 0.95
setupMethod · 0.95
transferPropertiesMethod · 0.95
okToDeleteRoiMethod · 0.80
deleteRoiMethod · 0.80
getRoiMethod · 0.45
getProcessorMethod · 0.45

Tested by

no test coverage detected