I want to binarize a gray image by value, so pixels that are between a and b will be 0, and 255 otherwise. I tried cv2.threshold
but this didn't produce the right effect. So I tried:
def cut(img,d,u):
for x,line in enumerate(img):
for y,px in enumerate(line):
if px < d or px > u:
img[x][y]=0
else:
img[x][y]=255
But this way is low performance, what is the right way to do that, use histogram equalization?