【问题标题】:how apply contrast to half of the image using openCV如何使用openCV将对比度应用于图像的一半
【发布时间】:2021-01-10 02:23:16
【问题描述】:

contrast_img = cv2.addWeighted(img, 2.5, np.zeros(img.shape, img.dtype), 0, 0)

如何更改一半图像的对比度,我正在使用上面的代码,我需要在我的代码中进行哪些更改

【问题讨论】:

  • 您好,欢迎来到 StackOverflow,请参阅提问指南。 stackoverflow.com/help/how-to-ask。请详细说明您想做什么,并发布您迄今为止尝试过的内容。
  • @saga_blast “图像的一半” 哪一半?上、下、右。离开了??
  • *图片的上半部分

标签: image-processing


【解决方案1】:

您可以切出图像的上半部分,然后对其应用对比度函数。

top_half = img[0:int(height/2), :, :];

我相当肯定,使用 python 别名将对比度应用到“top_half”也会改变原始的“img”,但如果不是这样,您总是可以将 top_half 覆盖到 img 上:

img[0:int(height/2), :, :] = top_half;

注意:opencv 中的图像是形状为 [height, width, channels] 的 numpy 数组(灰度图像或其他单通道表示可能缺少最后一维)。我在这里假设您正在使用 rgb(opencv 中的 bgr)图像。

【讨论】:

    猜你喜欢
    • 2021-08-14
    • 1970-01-01
    • 2012-05-20
    • 1970-01-01
    • 2021-03-13
    • 1970-01-01
    • 1970-01-01
    • 2017-01-11
    • 1970-01-01
    相关资源
    最近更新 更多