【问题标题】:Image blending in numpy returns plain white imagenumpy 中的图像混合返回纯白色图像
【发布时间】:2020-02-17 10:16:10
【问题描述】:

我正在尝试使用 numpy 而不是图像库来混合 2 个不同的图像。由于 numpy 使用数组,我使用下面的公式来混合图像:

    alpha = 0.8
    img_blend = img_1* (1.0 - alpha) + img_2* alpha
    io.imshow(img_blend)

由于某种原因,我不断得到一张纯白色的图像。 两张图片都正常显示,当我在它们上使用 io.imshow() 时,应用公式时会出现问题。

这是我使用 alpha 值的输出:

alpha = 0.9995:

阿尔法 = 1:

阿尔法 = 0:

【问题讨论】:

    标签: python python-3.x numpy image-processing


    【解决方案1】:

    在输入问题时,我发现出了什么问题,因此我将回答我自己的问题,以防任何人从中受益。

    添加 2 个 numpy 数组将我的数组值从 uint8 值转换为 float64 值。我找到的解决方案是将类型改回 uint8。

    img_blend = (img_1* (1.0 - alpha) + img_2* alpha).astype('uint8')
    

    最大的收获是侧面的彩条。最终图像如下所示:

    【讨论】:

      猜你喜欢
      • 2012-10-08
      • 1970-01-01
      • 1970-01-01
      • 2020-04-12
      • 2018-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-28
      相关资源
      最近更新 更多