python - How to inspect brightness of V channel with OpenCV? -


i need find way evaluate "brightness" of image. we're running through ocr system warns if image bright or dark, i'm not sure they're measuring exactly. i've assembled set of test data divided 3 categories: no warning, bright, dark. figured i'd convert image hsv , inspect v channel. frankly, don't entirely know i'm doing, , opencv docs python pretty opaque. got far calculating v channel histogram (although i'm not sure args correct):

def calc_hist(image_path):     image = cv2.imread(image_path)     image = imutils.resize(image, height=500)     hsv = cv2.cvtcolor(image, cv2.color_bgr2hsv)     hist = cv2.calchist([hsv], [2], none, [256], [0,256])     hist_array = hist.flatten() 

again, i'm not sure if inspecting histogram right approach, i'm trying come value approximates "brightness" can compare these groups of images , try find range of values our ocr software not throw warning.

assuming these right histograms, went on normalize them , compare mean standard deviation.


Comments