值方圖等化 import cv2 img=cv2.imread("8.png",0) cv2.imshow("IMG",img) dst=cv2.equalizeHist(img) cv2.imshow("DST",dst) cv2.waitKey(0) cv2.destroyAllWindows() 影像二值化 import cv2 a=cv2.imread("8.png",0) cv2.imshow("IMG",a) x=a.shape[0] y=a.shape[1] threshold=125 for i in range(x): for j in range(y): if(a[i][j]>threshold): a[i][j]=0 else: a[i][j]=255 cv2.imshow("threshold",a) cv2.waitKey(0) cv2.destroyAllWindows() 調整影像強度 import cv2 a=cv2.imread("8.png",0) cv2.imshow("IMG",a) x=a.shape[0] y=a.shape[1] for i in range(x): for j in range(y): a[i][j]=a[i][j]*0.7 cv2.imshow("dark",a) b=cv2.imread("8.png",0) for i in range(x): for j in range(y): b[i][j]=b[i][j]*1.5 if(int(b[i][j])>=int(255)): b[i][j]=int(255) cv2.imshow("bright",b) cv2.waitKey(0) cv2.destroyAllWindows() ...
留言
張貼留言