matlab学习笔记(八)---空域滤波增强

news/2024/7/7 9:51:17

1、平滑滤波器

1.1线性平滑滤波器

1.1.1给图像加入椒盐噪声

I=imread('eight.tif');
J=imnoise(I,'salt & pepper',0.02);
subplot(121),imshow(I),title('原始图像');
subplot(122),imshow(J),title('加入椒盐噪声的图像');
效果图如下:

1.1.2对一个图像进行不同大小模板的均值滤波,并比较结果

I=imread('eight.tif');
J=imnoise(I,'salt & pepper',0.02);
subplot(221),imshow(J),title('噪声图像');
K1=filter2(fspecial('average',3),J)/255;  %进行3*3模板的均值滤波
K2=filter2(fspecial('average',5),J)/255;  %进行5*5模板的均值滤波
K3=filter2(fspecial('average',7),J)/255;  %进行7*7模板的均值滤波
subplot(222),imshow(K1),title('3*3模板均值滤波');
subplot(223),imshow(K2),title('5*5模板均值滤波');
subplot(224),imshow(K3),title('7*7模板均值滤波');
效果图如下:


1.2非线性平滑滤波器

I=imread('eight.tif');
J=imnoise(I,'salt & pepper',0.02);
subplot(221),imshow(J),title('噪声图像');
K1=medfilt2(J,[3 3]);  %进行3*3模板的中值滤波
K2=medfilt2(J,[5 5]);  %进行5*5模板的中值滤波
K3=medfilt2(J,[7 7]);  %进行7*7模板的中值滤波
subplot(222),imshow(K1),title('3*3模板中值滤波');
subplot(223),imshow(K2),title('5*5模板中值滤波');
subplot(224),imshow(K3),title('7*7模板中值滤波');
效果图如下:




2、平滑滤波器

2.1线性锐化滤波器

2.1.1对图像cameraman.tif进行线性高通滤波

I=imread('cameraman.tif');
h=fspecial('laplacian');
I2=filter2(h,I);
subplot(121),imshow(I),title('原始图像');
subplot(122),imshow(I2),title('滤波后图像');
效果图如下:

2.1.2用sobel算子、prewitt算子、log算子对图像滤波

I=imread('rice.png');
subplot(221),imshow(I),title('原始图像');
h1=fspecial('sobel');
I1=filter2(h1,I);
subplot(222),imshow(I1),title('sobel算子滤波');
h1=fspecial('prewitt');
I1=filter2(h1,I);
subplot(223),imshow(I1),title('prewitt算子滤波');
h1=fspecial('log');
I1=filter2(h1,I);
subplot(224),imshow(I1),title('log算子滤波');
效果图如下




http://www.niftyadmin.cn/n/4464348.html

相关文章

va_start va_end

C语言中可变参数的用法 我们在C语言编程中会遇到一些参数个数可变的函数,例如printf() 这个函数,它的定义是这样的: int printf( const char* format, ...); 它除了有一个参数format固定以外,后面跟的参数的个数和类型是 可变的,例…

添加系统调用 http://docs.huihoo.com/joyfire.net/6-1.html

第一步:1.找到linux 内核代码所在地,一般在你的系统这个位置(你下载代码放其他地方我不反对) /usr/src/linux/ 但是也可能是这个位置 /usr/src/linux-2.4/或者其他 找到后cd /usr/src/linux*/ 转到该目录下. linux*表示代码所在的文件夹2.修改内核代码 a.添加源文件 假设新加…

matlab学习笔记(九)---频域增强

1、低通滤波 1.1对图像eight.tif加入椒盐噪声后,实现Butterworth低通滤波。 clear; I1imread(eight.tif); subplot(221),imshow(I1),title(原始图像); I2imnoise(I1,salt & pepper); %加入椒盐噪声 subplot(222),imshow(I2),title(噪声图像); fdouble(I2)…

matlab学习笔记(十)---边缘检测

分别采用roberts、sobel、prewitt、canny、log算子来检测图像的边缘并比较 Iimread(rice.png); B1edge(I,roberts); B2edge(I,sobel); B3edge(I,prewitt); B4edge(I,canny); B5edge(I,log); subplot(231),imshow(I),title(原始图像); subplot(232),imshow(B1),title(roberts算子…

2.6.8内核中通过模块添加系统调用,不用编译内核

我在2.6.8中通过模块添加系统调用,发现了两个问题:1.是sys_call_table的符号不可以被解析2.除了283 所有的系统调用号都已经被占用 ,且没有空余。(要是想添加的系统调用号大于283,我们就要先改变unistd.h中的NR_syscalls 改的大一…

fedora 升级内核

尽管在Fdora Core 8下可以使用yum升级内核,但是毕竟是别人编译通用内核,里面添加了很多自己系统不需要的模块,而自己需要的模块却没有开启。因此,学会自己手动编译升级内核也是必要的。 1、下载内核 linux内核可以从http://kernel…

matlab学习笔记(十一)---二值形态学运算

1、膨胀运算 1.1对图像text.png进行膨胀操作,并对比。 bwimread(text.png); sestrel(line,11,90); %创建一个线性结构元素 bw2imdilate(bw,se); %用线性结构元素来进行膨胀操作 subplot(121),imshow(bw),title(原始图像); subplot(122),imshow(bw2),title(膨…

向linux kernel 2.6.24.5中添加系统调用时的纠结

从www.kernel.org 下下载了 kernel 2.6.24.5的包,解压后放在 PC Ubuntu 8.04 /usr/src/ 下, 然后进入kernel源码文件树,进行了如下的步骤: 1. linux/kernel/sys.c 在该文件里增加了 一个自己的函数: asmlinkage void …