Record Class ContourFinderOp.Contour
java.lang.Object
java.lang.Record
cloud.opencode.base.image.analysis.ContourFinderOp.Contour
- Record Components:
points- the list of (x, y) boundary pixel coordinates | 边界像素坐标列表 (x, y)
- Enclosing class:
ContourFinderOp
A single contour consisting of boundary pixel coordinates.
由边界像素坐标组成的单个轮廓。
- Since:
- JDK 25, opencode-base-image V2.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublearea()Compute the area enclosed by this contour using the Shoelace formula.int[]Compute the bounding box of this contour.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.doubleCompute the perimeter of this contour as the sum of distances between consecutive points.List<int[]> points()Returns the value of thepointsrecord component.intsize()Get the number of points in this contour.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Contour
Create a contour with a defensive copy of the points list. 创建轮廓,对点列表进行防御性拷贝。- Parameters:
points- the list of boundary points | 边界点列表
-
-
Method Details
-
size
public int size()Get the number of points in this contour. 获取此轮廓中的点数。- Returns:
- the point count | 点数
-
area
public double area()Compute the area enclosed by this contour using the Shoelace formula. 使用鞋带公式计算此轮廓所围面积。The Shoelace formula computes the signed area of a polygon from its vertex coordinates. The absolute value is returned.
鞋带公式根据多边形顶点坐标计算有符号面积,返回绝对值。
- Returns:
- the area of the contour | 轮廓面积
-
perimeter
public double perimeter()Compute the perimeter of this contour as the sum of distances between consecutive points. 计算此轮廓的周长,即相邻点之间距离之和。- Returns:
- the perimeter length | 周长
-
boundingBox
public int[] boundingBox()Compute the bounding box of this contour. 计算此轮廓的边界框。- Returns:
- an array [x, y, width, height] of the bounding box | 边界框数组 [x, y, width, height]
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
points
-