简体   繁体   English

OpenCV和Python:如何使用二进制掩码降低亮度?

[英]OpenCV & Python: How to decrease brightness using binary mask?

I would like to darken one image based on the mask of an edge-detected second image. 我想根据边缘检测到的第二张图像的遮罩使一张图像变暗。

Image 1: Original (greyscale) image 图片1:原始(灰度)图片

在此处输入图片说明

Image 2: Edge detected (to be used as mask) 图片2:检测到边缘(用作遮罩)

在此处输入图片说明

Image 3: Failed example showing cv2.subtract processing 图3:显示cv2.subtract处理的失败示例

在此处输入图片说明

In my failed example (Image 3), I subtracted the white pixels (255) from the original image but what I want to do is DARKEN the original image based on a mask of the edge detected image. 失败的示例(图像3)中,我从原始图像中减去了白色像素(255),但我要基于边缘检测图像的遮罩来使原始图像暗淡

In this article: How to fast change image brightness with python + OpenCV? 在本文中: 如何使用python + OpenCV快速更改图像亮度? , Bill Gates describes how he converts the image to HSV, splits out then modifies Value , and then finally merges back. ,比尔·盖茨(Bill Gates)介绍了他如何将图像转换为HSV,拆分,修改Value以及最终合并。 This seems like a reasonable approach but I only want to modify the Value where the mask is white ie the edge exists. 这似乎是一种合理的方法,但我只想在蒙版为白色(即存在边缘)的地方修改“ 值”

Ultimately, I am trying to enhance the edge of a low resolution thermal video stream in a similar way to the FLIR One VividIR technology. 最终,我试图以类似于FLIR One VividIR技术的方式来增强低分辨率热视频流的边缘。

I believe that I've made it really far as a complete novice to image processing, OpenCV and Python but after days now of trying just about every function OpenCV offers, I've got myself stuck. 我相信我已经真正成为了图像处理,OpenCV和Python的一个完整的新手,但是经过几天的尝试,几乎可以尝试使用OpenCV提供的每个功能,但我还是陷入了困境。

## get the edge coordinates
pos = np.where(edge >0)
## divide 
img[pos] //=2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM