MATLAB学习笔记 函数记录(四)

colfilt(image, [m n], ‘sliding’, fun) 非线性空间滤波, 传入图片,滤波区域,和函数句柄

t = colfilt(g, [5 5], 'sliding', fun);
t = gscale(t, 'full16');

fspecial(type, paramters) 线性空间滤波器,type值有9种情况,对应paramters也不同

type : ‘average’ ‘disk’ ‘gaussian’ ‘laplacian’ ‘log’ ‘motion’ ‘prewitt’ ‘sobel’ ‘unsharp’
paramters: [r c] r [r c], sig alpha [r c], sig len, theta null null alpha (与上面的一一对应,null为没有)

f = imread('moon.jpg');
f = rgb2gray(f);
figure, imshow(f);title('none');
g = imfilter(tofloat(f), fspecial('average')); figure, imshow(g); title('arverage 3*3');
g = imfilter(tofloat(f), fspecial('disk')); figure, imshow(g); title('disk 5');
g = imfilter(tofloat(f), fspecial('gaussian')); figure, imshow(g); title('gaussian 3*3 0.5');
g = imfilter(tofloat(f), fspecial('laplacian')); figure, imshow(tofloat(f) - g); title('laplacian 0.2');
g = imfilter(tofloat(f), fspecial('log')); figure, imshow(tofloat(f) - g); title('log 5*5 0.5');
g = imfilter(tofloat(f), fspecial('motion')); figure, imshow(g); title('motion 9 0');
g = imfilter(tofloat(f), fspecial('prewitt')); figure, imshow(tofloat(f) - g); title('prewitt');
g = imfilter(tofloat(f), fspecial('sobel')); figure, imshow(tofloat(f) - g); title('sobel');
g = imfilter(tofloat(f), fspecial('unsharp')); figure, imshow(g); title('unsharp 0.2');
% close all % 关闭所有窗口

参数的具体定义直接输入 doc fspecial 即可
这里写图片描述
(另存为moon.jpg)

medfilt2(image, [x y], padpot) 非线性滤波器 [x y]默认为3*3表示滤波区域, padpot表示滤波方式,分为三种

padpot: ‘zero’ ‘symmetric’ ‘indexed’

f = imread('头像.jpg');
f = rgb2gray(f);
g = imnoise(f, 'salt & pepper', 0.2);
imshow(g);
t = medfilt2(g); figure, imshow(t);title('none 3*3');
t = medfilt2(g, 'zero'); figure, imshow(t);title('zero 3*3');
t = medfilt2(g, 'symmetric'); figure, imshow(t);title('symmetric 3*3');
t = medfilt2(g, 'indexed'); figure, imshow(t);title('indexed 3*3');
t = medfilt2(g, [4 4]); figure, imshow(t);title('none 4*4');
t = medfilt2(g, [4 4], 'zero'); figure, imshow(t);title('zero 4*4');
t = medfilt2(g, [4 4], 'symmetric'); figure, imshow(t);title('symmetric 4*4');
t = medfilt2(g, [4 4], 'indexed'); figure, imshow(t);title('indexed 4*4');
% close all % 关闭所有窗口

去燥效果明显,但是具体参数的话,还是看出来太大的差别(滤波区域的设定还是很重要地)。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值