When you are binarizing the image using the im2bw function, it uses a level value to determine the threshold. The default value of the level is 0.5. Hence all the pixels with values above 0.5 will be assigned 1. Since the pixel values in your image are between 0 and 255, the threshold of 0.5 is too small and will assign almost all pixels other than black with 1. This is why you are not getting the desired results.
If you want to use im2bw function please consider normalizing the input pixel values between 0 and 1. Also, tune the level value to get the desired output. For example, you can modify the second line as,