线性混合(cv::addWeighted):out = alpha·in + beta·in2 + gamma。双输入端口,常用于曝光合成、水印叠加、动画过渡。

所属模块:OpenCV 图像增强 · 任务类型:opencv_add_weighted

端口

输入

端口数据类型必填
in1Image / cv::Mat✓
in2Image / cv::Mat✓

输出

端口数据类型必填
outcv::Mat✓

参数

参数类型默认值范围 / 选项说明
alphafloat0.5[-10, 10]第一输入权重
betafloat0.5[-10, 10]第二输入权重
gammafloat0[-255, 255]加性偏移

示例图

示例图为最小可运行流水线(读取 → 处理 → 写出),可直接拖入 GraphStudio 或保存为 .json 后用 --open 打开;data/test.png 替换为实际图像路径。

{
  "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_add_weighted",
      "params": {
        "alpha": 0.5,
        "beta": 0.5,
        "gamma": 0
      }
    },
    {
      "id": "save",
      "type": "opencv_image_write",
      "params": {
        "file_path": "out_out.png"
      }
    }
  ],
  "edges": [
    {
      "from": "read1",
      "from_port": "out",
      "to": "node",
      "to_port": "in1"
    },
    {
      "from": "read2",
      "from_port": "out",
      "to": "node",
      "to_port": "in2"
    },
    {
      "from": "node",
      "from_port": "out",
      "to": "save",
      "to_port": "in"
    }
  ]
}

注意事项

  • 两路输入尺寸与通道数需一致。

本文是 GraphStudio 节点手册 系列文章之一;参数与行为以最新发布版为准。对应英文版见页面语言切换。