Class CannyOp
java.lang.Object
cloud.opencode.base.image.edge.CannyOp
Canny Edge Detection Operator
Canny 边缘检测算子
Implements the full Canny edge detection pipeline: Gaussian blur, Sobel gradient computation, non-maximum suppression, double thresholding, and hysteresis edge tracking. Produces a binary edge map (0 or 255).
实现完整的 Canny 边缘检测流程:高斯模糊、Sobel 梯度计算、 非极大值抑制、双阈值处理和滞后边缘跟踪。输出二值边缘图(0 或 255)。
Features | 主要功能:
- Full Canny pipeline with configurable thresholds - 完整 Canny 流程支持可配置阈值
- Gaussian smoothing via separable convolution (sigma=1.4) - 通过可分离卷积实现高斯平滑 (sigma=1.4)
- Non-maximum suppression for thin edges - 非极大值抑制实现细化边缘
- Hysteresis tracking for edge continuity - 滞后跟踪确保边缘连续性
- Binary output: only 0 or 255 pixel values - 二值输出:仅 0 或 255 像素值
Usage Examples | 使用示例:
// Canny with custom thresholds
Raster edges = CannyOp.apply(image, 50, 150);
// Canny with default thresholds (50, 150) and sigma=1.4
Raster edges = CannyOp.apply(image);
Performance | 性能特性:
- Time complexity: O(w * h) for each pipeline stage - 时间复杂度: 每个流水线阶段 O(w * h)
- Space complexity: O(w * h) for intermediate buffers - 空间复杂度: 中间缓冲区 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
-
apply
Apply Canny edge detection to aRasterwith default thresholds (50, 150) and sigma=1.4. Output is a binaryGRAY_8raster (only 0 or 255). 使用默认阈值 (50, 150) 与 sigma=1.4 对Raster应用 Canny 边缘检测。 输出二值GRAY_8raster(仅 0 或 255)。- Parameters:
raster- the source raster | 源 raster- Returns:
- the binary edge
GRAY_8raster | 二值边缘GRAY_8raster - Throws:
NullPointerException- if raster is null | 当 raster 为 null 时抛出- Since:
- opencode-base-image V1.0.4
-
apply
Apply Canny edge detection to aRasterwith specified thresholds and sigma=1.4. 使用指定阈值与 sigma=1.4 对Raster应用 Canny 边缘检测。- Parameters:
raster- the source raster | 源 rasterlowThreshold- hysteresis low threshold (must be >= 0) | 滞后低阈值highThreshold- hysteresis high threshold (must be >= low) | 滞后高阈值- Returns:
- the binary edge
GRAY_8raster | 二值边缘GRAY_8raster - Throws:
ImageOperationException- if thresholds are invalid | 阈值无效时抛出- Since:
- opencode-base-image V1.0.4
-