I have a grayscale image with 3 random values signified by integers 91, 123, 255. When I use gray2ind(I, 3) I get only 2 indices: 1 and 2. But when I use gray2ind(I, 2) I get 0 and 1 as expected. How come? I would expect gray2ind(I, 3) to give me 0, 1 and 2.
I do have a colormap array which I am planning to later use, which has 3 individual colors, such that after I would properly convert this to 0, 1 and 2 indices I'd just do imshow(gray2ind(I, 3), colors).