利用python将众多图片转化为二值灰度图
以下是我对单个图片转化为二值灰度图的程序,没有问题;import cv2
img = cv2.imread("/home/zhoudeliang/hed-master/image/train/75-1.jpg")
Grayimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(Grayimg, 1, 255,cv2.THRESH_BINARY)
cv2.imwrite('/home/zhoudeliang/hed-master/image/train-1/75-1.png', thresh)
以下是我对多个图片转化为二值灰度图的程序,存在问题,但我认为逻辑上说得过去呀,请指教!!
import cv2
while 1:
img = cv2.imread("/home/zhoudeliang/hed-master/image/train/75-1.jpg")
Grayimg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(Grayimg, 1, 255,cv2.THRESH_BINARY)
cv2.imwrite('/home/zhoudeliang/hed-master/image/train-1/75-1.png', thresh)
谢谢各位!!
谢谢