edu.emory.cellbio.ijbat.pi

## Class RoiUtils

• ```public class RoiUtils
extends Object```
Utility functions for working with regions of interest
Author:
Benjamin Nanes
• ### Constructor Summary

Constructors
Constructor and Description
`RoiUtils()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```distance(double[] A, double[] B)```
Compute the linear distance between two points.
`static double` ```distanceFromLine(double[] P, double[] A, double[] B)```
Compute the distance of point `P` from the line defined by points `A` and `B`.
`static double` ```distanceFromSegment(double[] P, double[] A, double[] B)```
Compute the distance of point `P` from the line segment bounded by points `A` and `B`.
`static double` ```distanceSquared(double[] A, double[] B)```
Compute the squared linear distance between two points.
`static boolean` ```isAbreastSegment(double[] P, double[] A, double[] B)```
Is a point next to a line segment? I.e.
`static boolean` ```isNearBorder(double[] P, net.imagej.overlay.AbstractOverlay overlay, double radius)```
Determine if a point is near a border defined by an set of vertices.
`static boolean` ```isNearBorder(double[] P, double[][] vertices, double radius, boolean closed)```
Determine if a point is near a border defined by an set of vertices.
`static boolean` ```isNearBorder(double[] P, net.imagej.overlay.GeneralPathOverlay overlay, double radius)```
Handler for `GeneralPathOverlay`s
`static boolean` ```isNearBorder(double[] P, net.imagej.overlay.LineOverlay overlay, double radius)```
Handler for `LineOverlay`s
`static boolean` ```isNearBorder(double[] P, net.imagej.overlay.PolygonOverlay overlay, double radius)```
Handler for `PolygonOverlay`s
`static double` ```triangleAltitude(double a, double b)```
Compute the altitude of a triangle.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### RoiUtils

`public RoiUtils()`
• ### Method Detail

• #### isNearBorder

```public static boolean isNearBorder(double[] P,
net.imagej.overlay.AbstractOverlay overlay,
throws SlideSetException```
Determine if a point is near a border defined by an set of vertices.
Parameters:
`P` - The point to check, `(x,y)`
`overlay` - Overlay to use as the border definition. If the overlay has more than two dimensions, it is flattened to `X` and `Y` dimensions only.
`radius` - Distance considered to be near the border
Throws:
`SlideSetException` - The overlay type is not supported
• #### isNearBorder

```public static boolean isNearBorder(double[] P,
net.imagej.overlay.PolygonOverlay overlay,
Handler for `PolygonOverlay`s
• #### isNearBorder

```public static boolean isNearBorder(double[] P,
net.imagej.overlay.LineOverlay overlay,
Handler for `LineOverlay`s
• #### isNearBorder

```public static boolean isNearBorder(double[] P,
net.imagej.overlay.GeneralPathOverlay overlay,
Handler for `GeneralPathOverlay`s
• #### isNearBorder

```public static boolean isNearBorder(double[] P,
double[][] vertices,
boolean closed)```
Determine if a point is near a border defined by an set of vertices.
Parameters:
`P` - The point to check, `(x,y)`
`vertices` - Ordered set of vertices defining the border, `[index][(x,y)]`
`radius` - Distance considered to be near the border
`closed` - Is the border closed, i.e. is the segment connecting the last and first points in the border set considered part of the border?
• #### distanceFromSegment

```public static double distanceFromSegment(double[] P,
double[] A,
double[] B)```
Compute the distance of point `P` from the line segment bounded by points `A` and `B`.
• #### distanceFromLine

```public static double distanceFromLine(double[] P,
double[] A,
double[] B)```
Compute the distance of point `P` from the line defined by points `A` and `B`.
• #### isAbreastSegment

```public static boolean isAbreastSegment(double[] P,
double[] A,
double[] B)```
Is a point next to a line segment? I.e. does the shortest line connecting point `P` to the line defined by points `A` and `B` intersect with line `A-B` between `A` and `B`?
• #### distance

```public static double distance(double[] A,
double[] B)```
Compute the linear distance between two points.
• #### distanceSquared

```public static double distanceSquared(double[] A,
double[] B)```
Compute the squared linear distance between two points.
• #### triangleAltitude

```public static double triangleAltitude(double a,
double b)```
Compute the altitude of a triangle. Returns `0` if one of the sides has length `0`.