function f = adpmedian(g, Smax)
% ADPMEDIAN Perform adaptivev median filtering.
% F = ADPMEDIAN(G, SMAX) performs adaptive median filtering of image G.
% The median filter starts at size 3-by-3 and iterates up to size
% SMAX-by-SMAX. SMAX must be an odd integer greater than 1.
% SMAX must be an odd, positive integer greater than 1.
if (Smax <= 1)|(Smax/2 == round(Smax/2))|(Smax ~= round(Smax))
error('Smax must be an odd integer >1.')
end
% Initial setup
f = g;
f(:) = 0;
alreadyProcessed = false(size(g));
% Begin filtering
for k = 3:2:Smax
zmin = ordfilt2(g, 1, ones(k,k), 'symmetric');
zmax = ordfilt2(g, k*k, ones(k,k), 'symmetric');
zmed = medfilt2(g, [k k], 'symmetric');
processUsingLevelB = (zmed > zmin) & (zmax > zmed) & ~alreadyProcessed;
zB = (g > zmin) & (zmax > g);
outputZxy = processUsingLevelB & zB;
【MATLAB】图像处理相关函数adpmedian函数
最新推荐文章于 2021-12-21 14:12:10 发布
本文详细介绍了MATLAB中用于图像处理的adpmedian函数,该函数实现自适应中值滤波,能有效去除噪声并保持图像细节。通过对不同应用场景的示例,展示了adpmedian函数的使用方法及其优势。
摘要由CSDN通过智能技术生成