how can i solve problem in my code for adaptive median filter
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Daleel Ahmed
am 28 Okt. 2017
Beantwortet: Zeeshan Salam
am 24 Mär. 2019
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 Kommentar
Akzeptierte Antwort
Walter Roberson
am 28 Okt. 2017
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.
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!