MatLab 数字图像处理实验 图像分割

实验(1)以chair.jpg图像为例,分别采用sobel、prewitt、robertslog对该图像及其加上噪声后的图像进行边缘检测。

close all
clear all
I=imread('D:/chair.jpg');
I_noise=imnoise(I,'gaussian',0.06);
bw1=edge(I_noise,'sobel');
bw2=edge(I_noise,'prewitt');
bw3=edge(I_noise,'roberts');
bw4=edge(I_noise,'log',[],4);
subplot(2,3,1);imshow(I);xlabel('原图');
subplot(2,3,2);imshow(I_noise,[]);xlabel('加入高斯噪声后的图像'); 
subplot(2,3,3);imshow(bw1);xlabel('Sober算子'); 
subplot(2,3,4);imshow(bw2);xlabel('Prewitt算子'); 
subplot(2,3,5);imshow(bw3);xlabel('Robrtts算子'); 
subplot(2,3,5);imshow(bw4);xlabel('LoG算子'); 

在这里插入图片描述

实验(2)以cell.jpg图像为例,分别迭代式阈值选择法最大类间方差阈值选择法对该图像进行分割。

clc
close all
clear all
I=imread('D:/cell.jpg');
I=im2double(I);
[width.heoght]=size(I)
T1=graythresh(I);
BW1=im2bw(I,T1);
f=double(I);
T=(min(f(:))+max(f(:)))/2;
done=false;
i=0;
while~done
    r1=find(f<=T);
    r2=find(f>T);
    Tnew=(mean(f(r1))+mean(f(r2)))/2
    done=abs(Tnew-T)<1
    T=Tnew;
    i=i+1;
end
f(r1)=0;
f(r2)=1;
subplot(1,3,1);imshow(I);xlabel('原图');
subplot(1,3,2);imshow(f);xlabel('迭代式阈值选择法');
subplot(1,3,3);imshow(BW1);xlabel('Otsu算法');

在这里插入图片描述

参考:https://blog.csdn.net/uchihalyn/article/details/104593878

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值