I am trying to convert a grayscale image into a binary image with two thresholds:
- img = a grayscale image
- b = the output binary image
- if (img > t1) or (img < t2) then b = 1
- otherwise b = 0
t1 = 200;t2 = 100;src = imread('an rgb image');img = reg2gray(src);b1 = imbinarize(img, t1);b2 = imbinarize(img, -t2);b = imadd(b1,b2);
but this code doesn't work. Is there a function to set multiple thresholds at the same time?
Best Answer