Watershed (cv::watershed). Needs the input image plus a marker map (distinct integer labels as seeds, 0 = unknown); flooding over the gradient terrain yields boundaries. Upstream, opencv_threshold + opencv_connected_components typically build the markers.

Module:OpenCV segmentation · Task type:opencv_watershed

Ports

Inputs

PortTypeRequired
inImage / cv::Mat✓
markersImage / cv::Mat—

Outputs

PortTypeRequired
outcv::Mat✓

Parameters

参数类型默认值范围 / 选项说明
rect_xint-1[-1, 16384]
rect_yint-1[-1, 16384]
rect_widthint-1[-1, 16384]
rect_heightint-1[-1, 16384]

Example graph

A minimal runnable pipeline (read → process → write). Drag it into GraphStudio or open via --open; replace data/test.png with a real path.

{
  "version": "2.0",
  "tasks": [
    {
      "id": "read1",
      "type": "opencv_image_read",
      "params": {
        "file_path": "data/test.png"
      }
    },
    {
      "id": "read2",
      "type": "opencv_image_read",
      "params": {
        "file_path": "data/test.png"
      }
    },
    {
      "id": "node",
      "type": "opencv_watershed",
      "params": {
        "rect_x": -1,
        "rect_y": -1,
        "rect_width": -1,
        "rect_height": -1
      }
    },
    {
      "id": "save",
      "type": "opencv_image_write",
      "params": {
        "file_path": "out_out.png"
      }
    }
  ],
  "edges": [
    {
      "from": "read1",
      "from_port": "out",
      "to": "node",
      "to_port": "in"
    },
    {
      "from": "read2",
      "from_port": "out",
      "to": "node",
      "to_port": "markers"
    },
    {
      "from": "node",
      "from_port": "out",
      "to": "save",
      "to_port": "in"
    }
  ]
}

Part of the GraphStudio node guide series; parameters reflect the latest release.