简体   繁体   中英

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

在此处输入图片说明

Image 2: Edge detected (to be used as mask)

在此处输入图片说明

Image 3: Failed example showing cv2.subtract processing

在此处输入图片说明

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.

In this article: How to fast change image brightness with python + OpenCV? , Bill Gates describes how he converts the image to HSV, splits out then modifies Value , and then finally merges back. 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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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