I would like to binarize a whole folder of images and save them. I've already found a code that binarizes a single image and store it in the same folder:
import cv2
im_gray = cv2.imread('blurredimg1.png', cv2.IMREAD_GRAYSCALE)
(thresh, im_bw) = cv2.threshold(im_gray, 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
thresh = 127
im_bw = cv2.threshold(im_gray, thresh, 255, cv2.THRESH_BINARY)[1]
cv2.imwrite('bw_image.png', im_bw)
Here's the output
Now, I would like to use the threshold on the entire set at once. How can I do so ?