基于MATLAB的图像分割技术Word格式.docx
- 文档编号:14981145
- 上传时间:2022-10-26
- 格式:DOCX
- 页数:16
- 大小:559.57KB
基于MATLAB的图像分割技术Word格式.docx
《基于MATLAB的图像分割技术Word格式.docx》由会员分享,可在线阅读,更多相关《基于MATLAB的图像分割技术Word格式.docx(16页珍藏版)》请在冰豆网上搜索。
t
t=
0.4691
r=im2bw(f,t);
subplot(2,2,1);
imshow(f);
subplot(2,2,2);
imshow(r);
xlabel('
迭代法全局阀值分割'
th=graythresh(f);
th
th=
0.3961
s=im2bw(f,th);
subplot(2,2,3);
imshow(s);
全局阀值Otsu分割'
se=strel('
disk'
10);
ft=imtophat(f,se);
thr=graythresh(ft);
thr
thr=
0.1098
lt=im2bw(ft,thr);
subplot(2,2,4);
imshow(lt);
局部阀值分割'
用迭代法对图像进行分割:
i=imread('
eight.tif'
zmax=max(max(i));
zmin=min(min(i));
tk=(zmax+zmin)/2;
bcal=1;
isize=size(i);
while(bcal)
ifg=0;
ibg=0;
fg=0;
bg=0;
forj=1:
isize
(1)
fork=1:
isize
(2)
tmp=i(j,k);
if(tmp>
=tk)
ifg=ifg+1;
fg=fg+double(tmp);
else
ibg=ibg+1;
bg=bg+double(tmp);
zo=fg/ifg;
zb=bg/ibg;
tktmp=uint8((zo+zb)/2);
if(tktmp==tk)
bcal=0;
tk=tktmp;
disp(strcat('
迭代后阀值'
num2str(tk)));
迭代后阀值165
newi=im2bw(i,double(tk)/255);
subplot(1,2,1);
imshow(i);
subplot(1,2,2);
imshow(newi);
迭代法'
用Otsu法进行阀值选择:
coins.png'
bw=im2bw(i,graythresh(getimage));
imshow(bw);
使用分水岭算法对图像进行分割:
c1=-10;
c2=-c1;
dist=sqrt(2*(2*c1)^2);
rad=dist/2*1.4;
li=[floor(c1-1.2*rad)ceil(c2+1.2*rad)];
[x,y]=meshgrid(li
(1):
li
(2));
bw1=sqrt((x-c1).^2+(y-c1).^2)<
=rad;
bw2=sqrt((x-c2).^2+(y-c2).^2)<
bw=bw1|bw2;
subplot(1,3,1);
d=bwdist(~bw);
subplot(1,3,2);
imshow(d,[]);
d=-d;
d(~bw)=-Inf;
l=watershed(d);
rgb=label2rgb(l,'
jet'
[.5.5.5]);
subplot(1,3,3);
imshow(rgb);
使用分水岭算法:
dist=sqrt(3*(2*c1)^2);
[x,y,z]=meshgrid(li
(1):
bw1=sqrt((x-c1).^2+(y-c1).^2+(z-c1).^2)<
bw2=sqrt((x-c2).^2+(y-c2).^2+(z-c2).^2)<
figure;
isosurface(x,y,z,bw,0.5);
axisequal;
set(gcf,'
color'
'
w'
xlim(li);
ylim(li);
zlim(li);
view(3);
camlight;
lightinggouraud;
isosurface(x,y,z,d,rad/2);
isosurface(x,y,z,l==2,0.5);
isosurface(x,y,z,l==3,0.5);
axisequal;
改进的Watershed算法分割图像:
cameraman.tif'
subplot(2,3,1);
i=double(i);
hv=fspecial('
prewitt'
hh=hv.'
;
gv=abs(imfilter(i,hv,'
replicate'
));
gh=abs(imfilter(i,hh,'
g=sqrt(gv.^2+gh.^2);
subplot(2,3,2);
df=bwdist(i);
imshow(uint8(df*8));
l=watershed(df);
em=l==0;
subplot(2,3,3);
imshow(em);
im=imextendedmax(i,20);
subplot(2,3,4);
imshow(im);
g2=imimposemin(g,im|em);
subplot(2,3,5);
imshow(g2);
l2=watershed(g2);
wr2=l2==0;
i(wr2)=255;
subplot(2,3,6);
imshow(uint8(i));
使用区域生长法对图像进行分割:
i=rgb2gray(i);
i1=double(i);
s=255;
t=55;
ifnumel(s)==1
si=i1==s;
s1=s;
si=bwnorph(s,'
shrink'
Inf);
j=find(si);
s1=i1(j);
ti=false(size(i1));
length(s1)
sv=s1(k);
s=abs(i1-sv)<
ti=ti|s;
[g,nr]=bwlabel(imreconstruct(si,ti));
imshow(g);
nr
nr=
2
对给定图像进行四叉树分解:
liftingbody.png'
s=qtdecomp(i,.27);
blocks=repmat(uint8(0),size(s));
fordim=[512256128643216842];
numblocks=length(find(s==dim));
if(numblocks>
0)
values=repmat(uint8
(1),[dimdimnumblocks]);
values(2:
dim,2:
dim,:
)=0;
blocks=qtsetblk(blocks,s,dim,values);
blocks(end,1:
end)=1;
blocks(1:
end,end)=1;
imshow(blocks,[]);
提取四叉树分解的子块信息:
i=[11112366
11214568
1111101577
1111202577
202220221234
202222205678
202220209101112
2222202013141516];
s=qtdecomp(i,5);
[vals,r,c]=qtgetblk(i,s,4)
vals(:
:
1)=
1111
1121
2)=
20222022
20222220
20222020
22222020
r=
1
5
c=
newvals=cat(3,zeros(4),ones(4));
j=qtsetblk(i,s,4,newvals)
j=
00002366
00004568
0000101577
0000202577
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 MATLAB 图像 分割 技术