![](/img/trans.png)
[英]How to auto adjust contrast and brightness of a scanned Image with opencv python
[英]Is that possible to adjust the brightness to be more darkest in the image using opencv in python?
您可以更改整個圖片的亮度,但我不確定如何制作它的一部分。 我認為這個鏈接可以幫助你。
這是第一步和結果的解決方案。
import cv2
img=cv2.imread("/ur/source/image/bright.png")
height, width, channels = img.shape
thresh = [100,100,100]
white = [255,255,255]
white_counter = 0
for x in range(0,width):
for y in range(0,height):
channels_xy = img[y,x]
if all(channels_xy >= thresh):
white_counter += 1
if(white_counter>55):
for k in range(0,height):
img[k,x] = white
white_counter = 0
cv2.imshow('Result',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
結果:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.