将视频音调更改为sepi

2024-05-19 02:27:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Python把视频的音调改成棕褐色。下面是我使用OpenCV的方法:

def sepia(rgb):
    b,g,r = cv2.split(rgb)
    red = r * 0.393 + g* 0.769 + b* 0.189
    green = r * 0.349 +g * 0.686 + b* 0.168
    blue = r* 0.272 + g* 0.534 + b * 0.131
    return cv2.merge((blue,green,red))

我的输出是:

{1美元^

更新

似乎,当我用

^{pr2}$

它显示一个完美的灰度,而这个:

^{3}$

显示黑白图像。在


Tags: 方法视频returndefgreenbluergbred
1条回答
网友
1楼 · 发布于 2024-05-19 02:27:48

我不能肯定,因为你没有发布代码。请注意,imshow有解释输入数组类型的方法,请参见here

  • If the image is 8-bit unsigned, it is displayed as is.
  • If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the value range [0,255*256] is mapped to [0,255].
  • If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].

相关问题 更多 >

    热门问题