Class RasterPipeline

java.lang.Object
cloud.opencode.base.image.raster.RasterPipeline

public final class RasterPipeline extends Object
Lightweight fluent helper for chaining Raster-native operations. 链式调用 Raster 原生操作的轻量门面。

Wraps a Raster so callers can chain the migrated subset of operations (threshold / Otsu / morphology) without juggling intermediate variables. The pipeline is immutable — each method returns a new pipeline holding the produced Raster.

包装 Raster,让调用方可以链式串联已迁移的操作子集 (threshold / Otsu / morphology),而无需手工管理中间变量。 Pipeline 不可变 —— 每个方法都返回承载新 Raster 的新 pipeline。

Scope | 范围: Exposes the threshold / Otsu / morphology stages as a fluent chain. Other Raster operations (filter / edge / feature / etc.) are invoked directly via their apply(Raster, ...) entry points.

范围: 以流式链路暴露 threshold / Otsu / morphology 阶段。 其他 Raster 操作(filter / edge / feature 等)通过各自的 apply(Raster, ...) 直接调用。

Usage Examples | 使用示例:

Raster result = RasterPipeline.of(src)
        .otsu()
        .open(StructuringElement.rect(3, 3))
        .toRaster();

Thread safety | 线程安全: Immutable; safe for concurrent reuse, but the wrapped Raster itself is mutable — do not mutate it from another thread while building a chain. 不可变;并发复用安全,但内部包装的 Raster 本身可变 —— 构建链路期间 不要从其他线程修改它。

Since:
JDK 25, opencode-base-image V1.0.4
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • of

      public static RasterPipeline of(Raster raster)
      Creates a new pipeline wrapping the given raster. 创建包装给定 raster 的新 pipeline。
      Parameters:
      raster - the source raster (non-null) | 源 raster(非空)
      Returns:
      a new pipeline | 新的 pipeline
      Throws:
      NullPointerException - if raster is null | 当 raster 为 null 时抛出
    • threshold

      public RasterPipeline threshold(int threshold)
      Apply fixed BINARY threshold. 应用固定 BINARY 阈值。
      Parameters:
      threshold - the threshold value [0, 255] | 阈值 [0, 255]
      Returns:
      a pipeline holding the thresholded GRAY_8 raster | 承载阈值处理后 GRAY_8 raster 的 pipeline
      See Also:
    • threshold

      public RasterPipeline threshold(int threshold, ThresholdOp.Mode mode)
      Apply fixed threshold with the specified mode. 使用指定模式应用固定阈值。
      Parameters:
      threshold - the threshold value [0, 255] | 阈值 [0, 255]
      mode - the threshold mode | 阈值模式
      Returns:
      a pipeline holding the thresholded GRAY_8 raster | 承载阈值处理后 GRAY_8 raster 的 pipeline
      See Also:
    • otsu

      public RasterPipeline otsu()
      Apply Otsu automatic thresholding. 应用大津法自动阈值。
      Returns:
      a pipeline holding the GRAY_8 binary raster | 承载 GRAY_8 二值 raster 的 pipeline
      See Also:
    • erode

      public RasterPipeline erode(StructuringElement element)
      Apply morphological erosion. 应用形态学腐蚀。
      Parameters:
      element - the structuring element | 结构元素
      Returns:
      a pipeline holding the eroded GRAY_8 raster | 承载腐蚀后 GRAY_8 raster 的 pipeline
      See Also:
    • dilate

      public RasterPipeline dilate(StructuringElement element)
      Apply morphological dilation. 应用形态学膨胀。
      Parameters:
      element - the structuring element | 结构元素
      Returns:
      a pipeline holding the dilated GRAY_8 raster | 承载膨胀后 GRAY_8 raster 的 pipeline
      See Also:
    • open

      public RasterPipeline open(StructuringElement element)
      Apply morphological opening (erosion followed by dilation). 应用形态学开运算(先腐蚀后膨胀)。
      Parameters:
      element - the structuring element | 结构元素
      Returns:
      a pipeline holding the opened GRAY_8 raster | 承载开运算后 GRAY_8 raster 的 pipeline
      See Also:
    • close

      public RasterPipeline close(StructuringElement element)
      Apply morphological closing (dilation followed by erosion). 应用形态学闭运算(先膨胀后腐蚀)。
      Parameters:
      element - the structuring element | 结构元素
      Returns:
      a pipeline holding the closed GRAY_8 raster | 承载闭运算后 GRAY_8 raster 的 pipeline
      See Also:
    • toRaster

      public Raster toRaster()
      Returns the current raster held by this pipeline. 返回此 pipeline 当前持有的 raster。
      Returns:
      the raster | raster