我在此描述中附上了這張圖片。我想在影像的任何位置選擇一個區域并增加其亮度而不影響影像的其他部分。如何在python OpenCV中處理這種情況。
黑色矩形中某個區域的亮度應該受某個標量的影響。
任何的想法。

uj5u.com熱心網友回復:
這是在 Python/OpenCV 中執行此操作的一種方法。
裁剪區域。增加它的亮度。然后將修改后的區域放回影像中。
輸入:

import cv2
import numpy as np
# load image
img = cv2.imread('orange_flower.jpg')
# specify region
x,y,w,h = 480,183,163,115
# crop region
crop = img[y:y h, x:x w]
# increase brightness of crop
gain = 1.5
crop = (gain * crop.astype(np.float64)).clip(0,255).astype(np.uint8)
# put crop back into input
result = img.copy()
result[y:y h, x:x w] = crop
# save output
cv2.imwrite('orange_flower_result.jpg', result)
# Display various images to see the steps
cv2.imshow('result',result)
cv2.waitKey(0)
cv2.destroyAllWindows()
結果:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/358835.html
