通过阈值方法调整图片清晰程度
1、import cv2 as cvimport numpy as npfont = cv.FONT_HERSHEY_SIMPLEXimage = cv.imread("c:\\book.png")cv.imshow('image', image)加载图片

3、gray = c箪滹埘麽v.cvtColor(image, cv.COLOR_BGR2GRAY)retval1, threshold = cv.thr髫潋啜缅eshold(gray, 100, 255, cv.THRESH_BINARY)imgfont = cv.putText(threshold, 'threshold: 100,255', (100, 100), font, 1.2, (255, 255, 255), 2)cv.imshow('threshold', threshold)转化成灰度后二值化处理和上图比较:图片都变清晰但是边缘存在彩色阴影或者黑白阴影

5、adaptiveThresholdGaua = cv.adaptiveThreshold(gray, 255, cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY, 13, 9)imgfont = cv.putText(adaptiveThresholdGaua, 'adaptiveThresholdGaua: 13,9', (100, 100), font, 1.2, (255, 255, 255), 2)cv.imshow('adaptiveThresholdGaua', adaptiveThresholdGaua)采用自适应高斯大法。二值化,窗口大小选13,常数c选择9

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:58
阅读量:96
阅读量:35
阅读量:94
阅读量:38