图像处理MATLAB源码
来源:互联网 发布:淘宝试用成功后要钱吗 编辑:程序博客网 时间:2024/04/29 20:23
图像反转
I=imread('nickyboom.jpg');
J=double(I);J=-J+(256-1); %图像反转线性变换
H=uint8(J);
subplot(1,2,1),imshow(I);
subplot(1,2,2),imshow(H);
直方图均衡化
MATLAB 程序实现如下:
I=imread('nickyboom.jpg);
I=rgb2gray(I);
figure;
subplot(2,2,1);
imshow(I);
subplot(2,2,2);
imhist(I);
I1=histeq(I);
figure;
subplot(2,2,1);
imshow(I1);
subplot(2,2,2);
imhist(I1);
均值滤波器
I=imread('nickyboom.jpg');
subplot(231)
imshow(I)
title('原始图像')
I=rgb2gray(I);
I1=imnoise(I,'salt & pepper',0.02);
subplot(232)
imshow(I1)
title(' 添加椒盐噪声的图像')
k1=filter2(fspecial('average',3),I1)/255;
k2=filter2(fspecial('average',5),I1)/255;
k3=filter2(fspecial('average',7),I1)/255;
k4=filter2(fspecial('average',9),I1)/255;
subplot(233),imshow(k1);title('3*3 模板平滑滤波');
subplot(234),imshow(k2);title('5*5 模板平滑滤波');
subplot(235),imshow(k3);title('7*7 模板平滑滤波');
subplot(236),imshow(k4);title('9*9 模板平滑滤波');
中值滤波器
I=imread('nickyboom.jpg');
I=rgb2gray(I);
J=imnoise(I,'salt & pepper',0.02);
subplot(231),imshow(I);title('原图像');
subplot(232),imshow(J);title('添加椒盐噪声图像');
k1=medfilt2(J); %进行3*3模板中值滤波
k2=medfilt2(J,[5,5]); %进行5*5模板中值滤波
k3=medfilt2(J,[7,7]); %进行7*7模板中值滤波
k4=medfilt2(J,[9,9]); %进行9*9模板中值滤波
subplot(233),imshow(k1);title('3*3模板中值滤波');
subplot(234),imshow(k2);title('5*5模板中值滤波 ');
subplot(235),imshow(k3);title('7*7模 板中值滤波');
subplot(236),imshow(k4);title('9*9 模板中值滤波');
边缘检测
I=imread('nickyboom.jpg');
subplot(2,3,1);
imshow(I);
title('原始图像');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I1=im2bw(I);
subplot(2,3,2);
imshow(I1);
title('二值图像');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I2=edge(I1,'roberts');
subplot(2,3,3);
imshow(I2);
title('roberts算子边缘检测');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I3=edge(I1,'sobel');
subplot(2,3,4);
imshow(I3);
title('sobel算子边缘检测');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I4=edge(I1,'Prewitt');
subplot(2,3,5);
imshow(I4);
title('Prewitt算子边缘检测 ');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I5=edge(I1,'log');
subplot(2,3,6);
imshow(I5);
title('log算子边缘检测');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
自动阈值法:Otsu法
用MATLAB实现Otsu算法:
clc
clear all
I=imread('nickyboom.jpg');
subplot(1,2,1),imshow(I);
title('原始图像')
axis([50,250,50,200]);
grid on;
axis on;
level=graythresh(I);
BW=im2bw(I,level);
subplot(1,2,2),imshow(BW);
title('Otsu 法阈值分割图像')
axis([50,250,50,200]);
grid on;
axis on;
膨胀操作
I=imread('nickyboom.jpg');
I1=rgb2gray(I);
subplot(1,2,1);
imshow(I1);
title('灰度图像')
axis([50,250,50,200]);
grid on;
axis on;
se=strel('disk',1);
I2=imdilate(I1,se);
subplot(1,2,2);
imshow(I2);
title(' 膨胀后图像');
axis([50,250,50,200]);
grid on;
axis on;
腐蚀操作
MATLAB 实现腐蚀操作
I=imread('xian.bmp');
I1=rgb2gray(I);
subplot(1,2,1);
imshow(I1);
title('灰度图像')
axis([50,250,50,200]);
grid on;
axis on;
se=strel('disk',1);
I2=imerode(I1,se);
subplot(1,2,2);
imshow(I2);
title('腐蚀后图像');
axis([50,250,50,200]);
grid on;
axis on;
- 图像处理MATLAB源码
- 图像分割 处理 matlab源码
- 【MATLAB图像处理2】 直方图的均衡化(附源码)
- 【MATLAB图像处理3】 canny边缘检测 (附源码)
- 【MATLAB图像处理2】 直方图的均衡化(附源码)
- 【MATLAB图像处理3】 canny边缘检测 (附源码)
- matlab图像算法源码
- 【图像处理】MATLAB:图像噪声
- 【图像处理】MATLAB:图像压缩
- 【图像处理】MATLAB:图像分割
- MATLAB图像处理命令
- MATLAB 图像处理命令
- MATLAB图像处理基本知识
- Matlab 图像处理
- 关于matlab图像处理
- MATLAB图像处理基础
- Matlab处理图像二三例
- Matlab图像处理
- [TroubleShooting]Neither the partner nor the witness server instance for database is availble
- 【C++再学习】【07】自增自减操作符背后的秘密
- Python标准库-traceback模块
- 阿斯格德付费的
- yacc 编程
- 图像处理MATLAB源码
- rpm 安装mysql
- 拨号键盘匹配联系人问题
- Spring注解注入
- JsBridge实现JavaScript和Android的互相调用
- 获取字符串中特定字符的最后一个下标
- IOS学习之路七(通过xib自定义UITableViewCell)
- 电五找个师傅好不好
- 工作总结第一天,学会使用Git(1)