我的問題是如何在MATLAB的中心應用5×5拉普拉斯濾波器?如何在MATLAB中應用濾波器?
我試試這個代碼,但它不工作
kAvg = fspecial('average',[5 5]);
kLap = fspecial('laplacian');
我的問題是如何在MATLAB的中心應用5×5拉普拉斯濾波器?如何在MATLAB中應用濾波器?
我試試這個代碼,但它不工作
kAvg = fspecial('average',[5 5]);
kLap = fspecial('laplacian');
按照documentation,您可以使用imfilter
應用過濾器:
I = imread('cameraman.tif');
kLap = fspecial('laplacian');
filtered = imfilter(I,kLap,'replicate');
imshow(filtered); title('Filtered Image');
編輯:我只是意識到你問什麼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)');
請給出更多的上下文。在我的例子中,我看不到任何圖像。您是否看過http://www.mathworks.com/help/toolbox/images/ref/fspecial.html上的Matlab文檔?拉普拉斯與8在中心是什麼意思。拉普拉斯在中心有一個-1。 – 2012-03-06 12:38:50