Jaskehar S.

asked • 07/26/23

Matlab Code png to binary

I am having trouble converting my PNG image to binary. The image name is correct, but I am getting a confusing error on line 4. I put the code with the error mesage below. Thank you.


fullFileName = 'MatLabimage.png';

if exist(fullFileName, 'file')

rgbImage = imread(fullFileName);

binaryImage = im2bw(rgbImage, 0.4);

subplot(1, 2, 1);

imshow(rgbImage)

subplot(1, 2, 2);

imshow(binaryImage);

else

errorMessage = sprintf('Image file does not exist:\n%s', fullFileName);

uiwait(warndlg(errorMessage));

end


Unrecognized function or variable 'im2bw'.


Error in Binary3 (line 4)

binaryImage = im2bw(rgbImage, 0.4);

Joseph H.

What version of matlab are you using? This function also requires the image processing toolbox, you can check if it is installed with the “ver” command. im2bw is also deprecated, check out imbinarize instead. https://www.mathworks.com/help/images/ref/imbinarize.html
Report

07/31/23

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.