MATLAB: I try to use bwlabel, but there error that i can’t fix

-

>> BW=imread('b.jpg');
>> L=bwlabel(BW);
Error using bwlabel
Expected input number 1, BW, to be two-dimensional.
please help

Best Answer

jpg files are almost always RGB images even if they look like black and white. You need to rgb2gray() the content and perhaps im2bw() the result.