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

public static record ContourFinderOp.Contour(List<int[]> points) extends Record
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
    Constructor
    Description
    Contour(List<int[]> points)
    Create a contour with a defensive copy of the points list.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Compute the area enclosed by this contour using the Shoelace formula.
    int[]
    Compute the bounding box of this contour.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    double
    Compute the perimeter of this contour as the sum of distances between consecutive points.
    List<int[]>
    Returns the value of the points record component.
    int
    Get the number of points in this contour.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Contour

      public Contour(List<int[]> points)
      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

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • points

      public List<int[]> points()
      Returns the value of the points record component.
      Returns:
      the value of the points record component