东方之星
2010-07-15, 15:05
图像格式为512*512的bmp格式,利用MATLAB提取图像中阴影部分的面积。代码如下,但求得的结果有错误,请高人指点。
p=imread('C:\Documents and Settings\speedshi\桌面\0.bmp'); %读入图像
j=1; %以下程序是提取切片的边界
for i=1:512
q=find(p(i,: )==0);
if ~isempty(q)
j=j+1;
[q1,q2]=size(q);
e0(j,: )=[i,q(1),q(2)];
end
end
e=[e0(:,[1,2]);e0(:,[1,3])];
plot(e(:,2),e(:,1)) %画出所提取的边界
p=imread('C:\Documents and Settings\speedshi\桌面\0.bmp'); %读入图像
j=1; %以下程序是提取切片的边界
for i=1:512
q=find(p(i,: )==0);
if ~isempty(q)
j=j+1;
[q1,q2]=size(q);
e0(j,: )=[i,q(1),q(2)];
end
end
e=[e0(:,[1,2]);e0(:,[1,3])];
plot(e(:,2),e(:,1)) %画出所提取的边界