Class MorphologyOp
java.lang.Object
cloud.opencode.base.image.morphology.MorphologyOp
Morphological Image Operations
形态学图像操作工具类
Provides standard morphological operations on grayscale images: erosion, dilation, opening, closing, gradient, top-hat, and black-hat transforms.
提供灰度图像上的标准形态学操作:腐蚀、膨胀、开运算、闭运算、梯度、顶帽和黑帽变换。
Features | 主要功能:
- Erosion — minimum filter over structuring element - 腐蚀 — 结构元素上的最小值滤波
- Dilation — maximum filter over structuring element - 膨胀 — 结构元素上的最大值滤波
- Opening — erosion followed by dilation - 开运算 — 先腐蚀后膨胀
- Closing — dilation followed by erosion - 闭运算 — 先膨胀后腐蚀
- Gradient — dilation minus erosion - 梯度 — 膨胀减去腐蚀
- Top-hat — original minus opening - 顶帽 — 原图减去开运算
- Black-hat — closing minus original - 黑帽 — 闭运算减去原图
Usage Examples | 使用示例:
StructuringElement se = StructuringElement.rect(3, 3);
Raster eroded = MorphologyOp.erode(image, se);
Raster dilated = MorphologyOp.dilate(image, se);
Raster opened = MorphologyOp.open(image, se);
Raster edges = MorphologyOp.gradient(image, se);
Performance | 性能特性:
- Time complexity: O(w * h * kw * kh) per operation - 时间复杂度: 每次操作 O(w * h * kw * kh)
- Space complexity: O(w * h) for output image - 空间复杂度: 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 Summary
Modifier and TypeMethodDescriptionstatic RasterblackHat(Raster raster, StructuringElement element) Compute the black-hat transform (closing - original) on aRaster.static Rasterclose(Raster raster, StructuringElement element) Close aRaster(dilate then erode).static Rasterdilate(Raster raster, StructuringElement element) Dilate aRasterusing the given structuring element.static Rastererode(Raster raster, StructuringElement element) Erode aRasterusing the given structuring element.static Rastergradient(Raster raster, StructuringElement element) Compute the morphological gradient (dilate - erode) on aRaster.static Rasteropen(Raster raster, StructuringElement element) Open aRaster(erode then dilate).static RastertopHat(Raster raster, StructuringElement element) Compute the top-hat transform (original - opening) on aRaster.
-
Method Details
-
erode
- Parameters:
raster- the source raster | 源 rasterelement- the structuring element | 结构元素- Returns:
- the eroded
GRAY_8raster | 腐蚀后的GRAY_8raster - Throws:
NullPointerException- if any argument is null | 当任一参数为 null 时抛出- Since:
- opencode-base-image V1.0.4
-
dilate
- Parameters:
raster- the source raster | 源 rasterelement- the structuring element | 结构元素- Returns:
- the dilated
GRAY_8raster | 膨胀后的GRAY_8raster - Throws:
NullPointerException- if any argument is null | 当任一参数为 null 时抛出- Since:
- opencode-base-image V1.0.4
-
open
- Parameters:
raster- the source raster | 源 rasterelement- the structuring element | 结构元素- Returns:
- the opened
GRAY_8raster | 开运算后的GRAY_8raster - Since:
- opencode-base-image V1.0.4
-
close
- Parameters:
raster- the source raster | 源 rasterelement- the structuring element | 结构元素- Returns:
- the closed
GRAY_8raster | 闭运算后的GRAY_8raster - Since:
- opencode-base-image V1.0.4
-
gradient
- Parameters:
raster- the source raster | 源 rasterelement- the structuring element | 结构元素- Returns:
- the gradient
GRAY_8raster | 梯度GRAY_8raster - Throws:
NullPointerException- if any argument is null | 当任一参数为 null 时抛出- Since:
- opencode-base-image V1.0.4
-
topHat
- Parameters:
raster- the source raster | 源 rasterelement- the structuring element | 结构元素- Returns:
- the top-hat
GRAY_8raster | 顶帽GRAY_8raster - Throws:
NullPointerException- if any argument is null | 当任一参数为 null 时抛出- Since:
- opencode-base-image V1.0.4
-
blackHat
- Parameters:
raster- the source raster | 源 rasterelement- the structuring element | 结构元素- Returns:
- the black-hat
GRAY_8raster | 黑帽GRAY_8raster - Throws:
NullPointerException- if any argument is null | 当任一参数为 null 时抛出- Since:
- opencode-base-image V1.0.4
-