matlab 图像分割库,图像分割Matlab代码

41528d3028836879cd698677c3999917.gif图像分割Matlab代码

图像分割 Matlab 代码(一)图像边缘检测不同方法比较将 Roberts、Sobel、Prewitt、LOG、Canny 算子等经典图像分割算法对灰度图像分割的结果进行比较。Matlab 代码如下:%% 图像边缘检测不同方法比较% Roberts、 Sobel、Prewitt、LOG、Canny 算子对灰度图像分割的结果比较clc;clear all;close all;f=imread( 8_256_lena.bmp , bmp );subplot(2,3,1);subimage(f);title( 原始图像 );[g, t]=edge(f, roberts ,[], both );subplot(2,3,2);subimage(g);title( Roberts 算子对图像分割的结果 );[g, t]=edge(f, sobel ,[], both );subplot(2,3,3);subimage(g);title( Sobel 算子对图像分割的结果 );[g, t]=edge(f, prewitt ,[], both );subplot(2,3,4);subimage(g);title( Prewitt 算子对图像分割的结果 );[g, t]=edge(f, log );subplot(2,3,5);subimage(g);title( LOG 算子对图像分割的结果 );[g, t]=edge(f, canny );subplot(2,3,6);subimage(g);title( Canny 算子对图像分割的结果 );(二)区域生长法分割图像区域生长法分割图像,matlab 代码如下:%% 区域生长法分割图像clc;clear all;close all;f=imread( rice_1.bmp , bmp );% f=imread( rice.png , png );% f=imread( 8_256_lena.bmp , bmp );subplot(1,2,1);subimage(f); %选择三个种子点seedx=[63, 10, 85];%rice 图的生长点seedy=[30, 56, 60];% seedx=[100, 150, 227];%lena 图的生长点% seedy=[56, 130, 189];hold onplot(seedx,seedy, gs , linewidth ,1);title( 原始图像及种子点位置 );f=double(f);markerim=f==f(seedy(1),seedx(1));for i=2:length(seedx)markerim=markerim|(f==f(seedy(i),seedx(i)));end%3 个种子点区域的阈值thresh=[12,6,12];maskim= zeros(size(f));for i=1:length(seedx)g=abs(f-f(seedy(i),seedx(i)))T);Tnew=(mean(f(r1))+mean(f(r2)))/2;done=abs(Tnew-T)1;T=Tnew;i=i+1;endf(r1)=0;f(r2)=1;subplot(2,2,2);subimage(f);title( 迭代阈值二值化图像图像 );f=imread( 8_256_lena.bmp , bmp );subplot(2,2,3);subimage(f);title( 原始图像 );T=graythresh(f);g=im2bw(f,T);subplot(2,2,4);subimage(g);title( Otsu 方法二值化图像 );

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值