Returns the inverted roi, or null if this is not an area roi or cannot be converted to a ShapeRoi. If imp is not given, assumes a rectangle of size 2e9 2e9 for the boundary.
(ImagePlus imp)
| 1578 | /** Returns the inverted roi, or null if this is not an area roi or cannot be converted to a ShapeRoi. |
| 1579 | * If imp is not given, assumes a rectangle of size 2e9*2e9 for the boundary. */ |
| 1580 | public Roi getInverse(ImagePlus imp) { |
| 1581 | if (!isArea()) return null; |
| 1582 | Roi fullImage = (imp == null) ? new Roi(0,0, 2000000000, 2000000000) : new Roi(0,0, imp.getWidth(), imp.getHeight()); |
| 1583 | ShapeRoi s = (this instanceof ShapeRoi) ? (ShapeRoi)(this.clone()) : new ShapeRoi(this); |
| 1584 | if (s == null) return null; |
| 1585 | ShapeRoi inverse = s.xor(new ShapeRoi(fullImage)); |
| 1586 | return inverse.trySimplify(); |
| 1587 | } |
| 1588 | |
| 1589 | /** Returns a handle number if the specified screen coordinates are |
| 1590 | inside or near a handle, otherwise returns -1. */ |