用的是MATLAB R2019a
figure(1);
x=imread('lena.jpg');
subplot(1,3,1);
imshow(x);
subplot(1,3,2);
x_gray=rgb2gray(x);
imshow(x_gray);
subplot(1,3,3);
thresh = graythresh(x);
x_bw=imbinarize(x,thresh);
imshow(x_bw);
出错 imshow (line 246)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
倒数第二行改成 x_bw=imbinarize(x_gray,thresh);
x是彩色图像,是三维数组,x_gray是灰度图像,是二维数组,imbinarize()只能处理二维。