how can i solve problem in my code for adaptive median filter

조회 수: 10 (최근 30일)
Daleel Ahmed
Daleel Ahmed 2017년 10월 28일
답변: Zeeshan Salam 2019년 3월 24일
function f= dd(r,Smax)
if (Smax <= 1) | (Smax/2 == round(Smax/2)) | (Smax ~= round(Smax))
error('SMAX must be an odd integer > 1.')
end
[M, N] = size(r);
% Initial setup.
f = r;
f(:) = 0;
alreadyProcessed = false(size(r));
%Begin filtering.
for k = 3:2:Smax
zmin = ordfilt2(r, 1, ones(k, k), 'symmetric');
zmax = ordfilt2(r, k * k, ones(k, k), 'symmetric');
zmed = medfilt2(r, [k k], 'symmetric');
processUsingLevelB = (zmed > zmin) & (zmax > zmed) & ...
~alreadyProcessed;
zB = (r > zmin) & (zmax > r);
outputZxy = processUsingLevelB & zB;
outputZmed = processUsingLevelB & ~zB;
f(outputZxy) = r(outputZxy);
f(outputZmed) = zmed(outputZmed);
alreadyProcessed = alreadyProcessed | processUsingLevelB;
if all(alreadyProcessed(:))
break;
end
end
% Output zmed for any remaining unprocessed pixels. Note that this
% zmed was computed using a window of size Smax-by-Smax, which is
% the final value of k in the loop.
f(~alreadyProcessed) = zmed(~alreadyProcessed);
  댓글 수: 1
Daleel Ahmed
Daleel Ahmed 2017년 10월 28일
편집: Walter Roberson 2017년 10월 28일
Error using ordfilt2
Expected input number 1, A, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was char.

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

채택된 답변

Walter Roberson
Walter Roberson 2017년 10월 28일
You appear to be attempting to pass in characters for the first input to your function, the one named "r" here. That input must be numeric for this code to work.

추가 답변 (1개)

Zeeshan Salam
Zeeshan Salam 2019년 3월 24일
can u send me working of this algorithm and flowchart

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by