在线急等MATLAB高手解决MATLAB编程问题 运行不出 不知道什么错误

来源:百度知道 编辑:UC知道 时间:2024/05/10 08:19:28
程序如下 谢谢~~~
%程序代码:test2.m
clear, close all,I = imread('rice.tif');
imshow(I)
background = imopen(I,strel('disk',15));
figure,imshow(background)
figure, surf(double(background(1:8:end,1:8:end))),zlim([0 255]);
(gca,'ydir','reverse');
I2 = imsubtract(I,background); figure, imshow(I2);
I3 = imadjust(I2, stretchlim(I2),[0 1]);figure, imshow(I3);
level = graythresh(I3);bw = im2bw(I3,level); figure, imshow(bw)
[labeled,numObjects] = bwlabel(bw,4);
grain = imcrop(labeled)
RGB_label = label2rgb(labeled, @spring,'c','shuffle');
figure,imshow(RGB_label);
graindata = regionprops(labeled,'basic')
graindata(51).Area, graindata(51).BoundingBox, graindata(51).Centroid
allgrains=[graindata.Area]
max(allgrains)
biggrain = find(allgrains==ans)
mean(allgrains)
hist(allgrains,20)
没有那句 我不小心粘上去了 不好意思

【1】(gca,'ydir','reverse');
这句是什么意思啊?

【2】继续。搞明白了。程序没有问题,通了,关键是执行到grain = imcrop(labeled) 时,要在第六个个图中(黑白图)左击鼠标【十字形】,之后就通了,呵呵。

%程序代码:test2.m
clear, close all,I = imread('rice.tif');
imshow(I)
background = imopen(I,strel('disk',15));
figure,imshow(background)
figure, surf(double(background(1:8:end,1:8:end))),zlim([0 255]);
%(gca,'ydir','reverse');
I2 = imsubtract(I,background); figure, imshow(I2);
I3 = imadjust(I2, stretchlim(I2),[0 1]);figure, imshow(I3);
level = graythresh(I3);bw = im2bw(I3,level); figure, imshow(bw)
[labeled,numObjects] = bwlabel(bw,4);

grain = imcrop(labeled) %就是它!!!

RGB_label = label2rgb(labeled, @spring,'c','shuffle');
figure,imshow(RGB_label);
graindata = regionprops(labeled,'basic')
graindata(51).Area, graindata(51).BoundingBox, graindata(51).Centroid
allgrain