필터 지우기
필터 지우기

Strange 3x3 Lowpass filter

조회 수: 2 (최근 30일)
Fabio Corres
Fabio Corres 2017년 3월 11일
편집: Fabio Corres 2017년 3월 12일
I need to perform an article about hdr imagining and i see a formula that smooth the pixel.But it is different formulla. Can someone help me to code it on matlab
but i think first iteration will be problem. when i and j start with 1 and k is -1 first iteration will be ymax(0,0) but there is no such a thing like that in MATLAB.I think we should add +1 near i+k and j+l.
Thank you

채택된 답변

Chad Greene
Chad Greene 2017년 3월 11일
It looks like a pretty straightforward 3x3 averaging filter. The catch is you have to start with (i=2,j=2) so i+(-1) will be 1 and same for j. You can do this pixel by pixel, or you can do it much faster with imfilter:
ylpf = imfilter(ymax,fspecial('average',[3 3]));
No loops necessary.
  댓글 수: 1
Chad Greene
Chad Greene 2017년 3월 11일
If you do not have the Image Processing toolbox, you can use conv2 instead:
P = peaks(50) + 2*rand(50);
% With image toolbox:
Pf = imfilter(P,fspecial('average',[3 3]));
% Without image toolbox:
Pf2 = conv2(P,ones(3)/9,'same');
figure
subplot(1,3,1)
imagesc(P)
title 'noisy data'
subplot(1,3,2)
imagesc(Pf)
title 'imfilter'
subplot(1,3,3)
imagesc(Pf2)
title 'conv2'

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 3월 11일
There is no problem if you restrict i to be in [2, (number of rows - 1)] and restrict j to be in [2, (number of columns - 1)]
For areas outside that, the formula is not well defined.
Note: consider using the single statement
y_lpf = conv2(y_max, ones(3,3)/9, 'same');
... except, that is, that the result is well defined at the edges.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by