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

Method and

ij/src/main/java/ij/plugin/frame/RoiManager.java:1801–1846  ·  view source on GitHub ↗

calculates the intersection of area, line and point selections. If there is one PointRoi in the list of selected Rois, the points inside all selected area rois are kept. If more than one PointRoi is selected, the PointRois get converted to area rois with each pixel containing at least one point s

()

Source from the content-addressed store, hash-verified

1799 * If more than one PointRoi is selected, the PointRois get converted to area rois with each pixel containing
1800 * at least one point selected. */
1801 void and() {
1802 ImagePlus imp = getImage();
1803 if (imp==null) return;
1804 Roi[] rois = getSelectedRoisAsArray();
1805 if (rois.length==1) {
1806 error("More than one item must be selected, or none");
1807 return;
1808 }
1809 int nPointRois = countPointRois(rois);
1810 ShapeRoi s1=null;
1811 PointRoi pointRoi = null;
1812 for (Roi roi : rois) {
1813 if (roi==null)
1814 continue;
1815 if (s1==null) {
1816 if (nPointRois==1 && roi.getType() == Roi.POINT) {
1817 pointRoi = (PointRoi)roi;
1818 continue; //PointRoi will be handled at the end
1819 }
1820 if (roi instanceof ShapeRoi)
1821 s1 = (ShapeRoi)roi.clone();
1822 else
1823 s1 = new ShapeRoi(roi);
1824 if (s1==null) continue;
1825 } else {
1826 if (nPointRois==1 && roi.getType()==Roi.POINT) {
1827 pointRoi = (PointRoi)roi;
1828 continue; //PointRoi will be handled at the end
1829 }
1830 ShapeRoi s2 = null;
1831 if (roi instanceof ShapeRoi)
1832 s2 = (ShapeRoi)roi.clone();
1833 else
1834 s2 = new ShapeRoi(roi);
1835 if (s2==null) continue;
1836 s1.and(s2);
1837 }
1838 }
1839 if (s1==null) return;
1840 if (pointRoi!=null)
1841 imp.setRoi(pointRoi.containedPoints(s1));
1842 else
1843 imp.setRoi(s1.trySimplify());
1844 if (record())
1845 Recorder.record("roiManager", "AND");
1846 }
1847
1848 void xor() {
1849 ImagePlus imp = getImage();

Callers 3

actionPerformedMethod · 0.95
runCommandMethod · 0.95
runMethod · 0.45

Calls 12

getImageMethod · 0.95
errorMethod · 0.95
countPointRoisMethod · 0.95
andMethod · 0.95
setRoiMethod · 0.95
containedPointsMethod · 0.95
trySimplifyMethod · 0.95
recordMethod · 0.95
recordMethod · 0.95
getTypeMethod · 0.65
cloneMethod · 0.65

Tested by

no test coverage detected