MATLAB: Image shows with imshowpair, but not with imshow

image processingimshowimshowpair

I am writing a function that reads an image and converts it to BW. I am able to use imshowpair to display the unedited and edited images next to each other, but can't individually show just the edited (BW) image. What should I do?
midAirImage = imread("MidAirTest.jpg");
bwImage = imbinarize(midAirImage,'adaptive','ForegroundPolarity','dark','Sensitivity',0.4);
imshowpair(midAirImage, bwImage, 'montage')

Best Answer

Your binary image should be 2 dimensional, if it is not convert the original image into gray cale and then create binary image,
midAirImage = imread("MidAirTest.jpg");
midAirImage = rgb2gray(midAirImage);
bwImage = imbinarize(midAirImage,'adaptive','ForegroundPolarity','dark','Sensitivity',0.4);
imshowpair(midAirImage, bwImage, 'montage')
imshow(bwImage);