
[英]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.