Difference in im2bw and imbinarize function while display the binary image

5 views (last 30 days)
BW=im2bw(I);
subplot(1,1,1), imshow(BW), title('BINARY')
I am getting the binary image as output when i run the above code but the same thing if i use imbinarize function than display the BW than i am getting the x & y axis plot. why is this ?
am using Matlab R2018a version tool.

Accepted Answer

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi on 16 Jul 2019
Hey Kavita!
From your question, I understand that you are using the commands ‘im2bw’ and ‘imbinarize’ to threshold an RGB color image. You are able to get the expected output from the ‘im2bw’ command, but you are not able to get the expected output when using ‘imbinarize’.
For both these commands, the acceptable input is a grayscale 2-D image. If you feed in an RGB color image directly into ‘imbinarize’, it will consider it as a 3-D volume instead and throw an error since you are trying to display a 3-D logical value. Hence, the displayed output will simply be an X-Y axis, followed by an error in MATLAB. However, when you use an RGB color image as input for ‘im2bw’, the image is automatically converted to grayscale before thresholding. So, no error will be thrown and you get the expected output.
If you wish to binarize an RGB color image, please use the ‘Color Thresholder’ app in MATLAB. You can find relevant documentation about the 'Color Thresholder' app here.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!