-1
我需要对已经通过同态滤波器的图像应用阈值。如何确定图像的阈值?
我的阈值必须是图像强度的平均+标准偏差。
我使用的阈值化code by Jan Motl如下:
function J = bernsen_thres(I)
T = thres_val(I);
J = bernsen(I, [T T],20,'replicate');
end
function T = thres_val(I)
mn = mean(I(:));
sd = std(double(I(:)));
thres = round((mn+sd));
if(is_odd(thres))
T = thres;
else
T = thres+1;
end
function ret = is_odd(val)
if(mod(val,2) == 0);
ret = 0;
else
ret = 1;
end
我使用的同态滤波器code from Steve Eddins如下,
clear_all();
I = gray_imread('cameraman.png');
I = steve_homo_filter(I);
Ithres = bernsen_thres(I);
imshowpair(I, Ithres, 'montage')
但输出完全是黑色的,
我应该怎么做才能解决这个问题?
放一个断点并检查'thres'是什么。 (检查后告诉我们)。 –
@TonyTannous,thres = 181; – anonymous
如果后者不是内置函数,你可以添加'steve_homo_filter'和'brensen'的代码吗? –