本文介绍了如何在MATLAB中应用过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是如何在MATLAB中以中心为8的情况应用5×5拉普拉斯滤波器?
My question is how do I apply a 5×5 Laplacian filter with 8 at the center in MATLAB?
我尝试使用此代码,但是它不起作用
I try this code but it does not work
kAvg = fspecial('average',[5 5]);
kLap = fspecial('laplacian');
推荐答案
根据文档,则可以使用imfilter
来应用过滤器:
According to the documentation, you can use imfilter
to apply a filter:
I = imread('cameraman.tif');
kLap = fspecial('laplacian');
filtered = imfilter(I,kLap,'replicate');
imshow(filtered); title('Filtered Image');
我刚刚意识到您在问什么对于:
I just realized what you were asking for:
I = imread('cameraman.tif');
% simple high pass filter
kLap = [-1, -1, -1;
-1, 8, -1;
-1, -1, -1];
filtered_3x3 = imfilter(I,kLap,'replicate');
imshow(filtered_3x3); title('Filtered Image (3x3)');
pause();
% another simple high pass filter
kLap = [-1 -3 -4 -3 -1;
-3 0 6 0 -3;
-4 6 20 6 -4;
-3 0 6 0 -3;
-1 -3 -4 -3 -1];
filtered_5x5 = imfilter(I,kLap,'replicate');
imshow( filtered_5x5 ); title('Filtered Image (5x5)');
这篇关于如何在MATLAB中应用过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!