I assume you use the mean of the three components instead of the function rgb2gray
because it has some advantages in your case. (rgb2gray
does something similar: it uses a weighted sum).
Subtracting the minimum and dividing by the maximum doesn't convert your image to binary. It will only scale all values to the range (0,1), which is the case in your example. This only means that all values are between 0 and 1, not exactly 0 or 1. If you want a binary image, i.e. only 0 and 1, you will need to use a threshold to convert the grayscale image to binary.
A method which is often used, is to calculate a threshold using Otsu's method:
threshold = graythresh(im); % calculate threshold
binaryImage = im2bw(im,threshold); % convert image to binary
If your image is saved as uint8
then normalizing the image should convert your image to binary, as uint8
only can handle integer numbers and any numbers between are rounded. That means you assume the optimal threshold to be at 0.5.