MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB图像处理] 对图像进行灰度转换,二值化,腐蚀和重采样等预处理的程序 (https://www.labfans.com/bbs/showthread.php?t=2673)

wangbo_19860519 2008-04-28 14:29

对图像进行灰度转换,二值化,腐蚀和重采样等预处理的程序
 
function img=myimgpreprocess(I)
Igray=rgb2gray(I);
Ibw=im2bw(Igray,graythresh(Igray));
Iedge=edge(uint8(Ibw));
se=strel('square',3);
Iedge2=imdilate(Iedge,se);
Ifill=imfill(Iedge2,'holes');
[Ilabel num]=bwlabel(Ifill);
Iprops=regionprops(Ilabel);
Ibox=[Iprops.BoundingBox];
Ibox=reshape(Ibox,[4 50]);
Ic=[Iprops.Centroid];
Ic=reshape(Ic,[2 50]);
Ic=Ic';
Ic(:,3)=(mean(Ic.^2,2)).^(1/2);
Ic(:,4)=1:50;
Ic2=sortrows(Ic,2);
for cnt=1:5
Ic2((cnt-1)*10+1:cnt*10,:)=sortrows(Ic2((cnt-1)*10+1:cnt*10,:),4);
end
Ic3=Ic2(:,1:2);
ind=Ic2(:,4);
for cnt=1:50
img{cnt}=imcrop(Ibw,Ibox(:,ind(cnt)));
end
这是对图像进行灰度转换。二值化。腐蚀。和重采样等预处理的程序。
其中:
Iprops=regionprops(Ilabel);
Ibox=[Iprops.BoundingBox];
Ibox=reshape(Ibox,[4 50]);
Ic=[Iprops.Centroid];
Ic=reshape(Ic,[2 50]);
Ic=Ic';
Ic(:,3)=(mean(Ic.^2,2)).^(1/2);
Ic(:,4)=1:50;
Ic2=sortrows(Ic,2);
for cnt=1:5
Ic2((cnt-1)*10+1:cnt*10,:)=sortrows(Ic2((cnt-1)*10+1:cnt*10,:),4);
end
Ic3=Ic2(:,1:2);
ind=Ic2(:,4);
for cnt=1:50
img{cnt}=imcrop(Ibw,Ibox(:,ind(cnt)));
end
谁能告诉我一下是什么意思,谢谢了!!!紧急求助,小弟先谢谢大家了:ft: :ft:

fanxing39 2008-04-28 22:14

[SIZE="4"]我帮你把这个帖子放到 图像处理的那个论坛里哦 [/SIZE]:smile:


所有时间均为北京时间。现在的时间是 03:21

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.