Class HarrisCornerOp

java.lang.Object
cloud.opencode.base.image.feature.HarrisCornerOp

public final class HarrisCornerOp extends Object
Harris Corner Detector Harris 角点检测器

Implements the Harris corner detection algorithm for identifying interest points in images where two edges meet, forming a corner.

实现 Harris 角点检测算法,用于识别图像中两条边缘相交形成角点的兴趣点。

Features | 主要功能:

  • Harris corner detection with configurable k and threshold - 可配置 k 和阈值的 Harris 角点检测
  • Top-N corner selection with automatic threshold - 自动阈值的 Top-N 角点选择
  • Corner response image generation for visualization - 生成角点响应图用于可视化
  • Non-maximum suppression (3x3 window) - 非极大值抑制(3x3 窗口)

Usage Examples | 使用示例:

// Detect corners with explicit parameters
List<double[]> corners = HarrisCornerOp.detect(image, 0.04, 1000.0);
for (double[] corner : corners) {
    System.out.printf("Corner at (%d, %d) response=%.2f%n",
        (int) corner[0], (int) corner[1], corner[2]);
}

// Detect top-N corners with automatic threshold
List<double[]> topCorners = HarrisCornerOp.detect(image, 50);

// Get response image for visualization
BufferedImage response = HarrisCornerOp.responseImage(image, 0.04);

Performance | 性能特性:

  • Time complexity: O(w * h * k) where k is kernel size - 时间复杂度: O(w * h * k),k 为卷积核大小
  • Space complexity: O(w * h) for gradient and response arrays - 空间复杂度: O(w * h) 用于梯度和响应数组

Security | 安全性:

  • Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
  • Null-safe: No - 空值安全: 否
Since:
JDK 25, opencode-base-image V2.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • detect

      public static List<double[]> detect(BufferedImage image, double k, double threshold)
      Detect Harris corners with explicit parameters. 使用显式参数检测 Harris 角点。

      Returns a list of detected corners, each represented as a double[3] array containing [x, y, response].

      返回检测到的角点列表,每个角点表示为 double[3] 数组,包含 [x, y, response]。

      Parameters:
      image - the source image | 源图像
      k - Harris sensitivity parameter (typically 0.04-0.06) | Harris 灵敏度参数(通常为 0.04-0.06)
      threshold - minimum corner response threshold | 最小角点响应阈值
      Returns:
      list of [x, y, response] for each detected corner | 每个检测到的角点的 [x, y, response] 列表
      Throws:
      ImageOperationException - if image is null | 当图像为 null 时抛出
    • detect

      public static List<double[]> detect(BufferedImage image, int maxCorners)
      Detect Harris corners with automatic threshold, returning at most maxCorners. 使用自动阈值检测 Harris 角点,最多返回 maxCorners 个角点。

      Uses default k=0.04 and selects the top-N corners by response strength after non-maximum suppression.

      使用默认 k=0.04,在非极大值抑制后按响应强度选择 Top-N 角点。

      Parameters:
      image - the source image | 源图像
      maxCorners - maximum number of corners to return | 返回的最大角点数
      Returns:
      list of [x, y, response] for each detected corner, sorted by response descending | 每个检测到的角点的 [x, y, response] 列表,按响应值降序排列
      Throws:
      ImageOperationException - if image is null or maxCorners is not positive | 当图像为 null 或 maxCorners 不为正数时抛出
    • responseImage

      public static BufferedImage responseImage(BufferedImage image, double k)
      Compute and return the Harris corner response image for visualization. 计算并返回 Harris 角点响应图用于可视化。

      The response values are normalized to [0, 255] for display. Positive responses (corners) appear as bright pixels.

      响应值被归一化到 [0, 255] 用于显示。正响应(角点)显示为亮像素。

      Parameters:
      image - the source image | 源图像
      k - Harris sensitivity parameter | Harris 灵敏度参数
      Returns:
      a grayscale image showing corner response | 显示角点响应的灰度图像
      Throws:
      ImageOperationException - if image is null | 当图像为 null 时抛出