资源简介
带色彩恢复的Retinex:MSRCR算法实现,matlab语言,测试通过
代码片段和文件信息
function msrcr=MSRCR(I)
if length(size(I))<2
disp(‘不是彩图‘);
return;
end
Ir=I(::1);
Ig=I(::2);
Ib=I(::3);
%设定参数
G = 30;%192
b = -6;%-30
alpha = 125;%125
beta = 1;%46
Ir_double=double(Ir);
Ig_double=double(Ig);
Ib_double=double(Ib);
sigma_1=10; %三个高斯核
sigma_2=80;
sigma_3=300;
[x y]=meshgrid((-(size(Ir2)-1)/2):(size(Ir2)/2)(-(size(Ir1)-1)/2):(size(Ir1)/2));
gauss_1=exp(-(x.^2+y.^2)/(2*sigma_1*sigma_1)); %计算高斯函数
Gauss_1=gauss_1/sum(gauss_1(:)); %归一化处理
gauss_2=exp(-(x.^2+y.^2)/(2*sigma_2*sigma_2));
Gauss_2=gauss_2/sum(gauss_2(:));
gauss_3=exp(-(x.^2+y.^2)/(2*sigma_3*sigma_3));
Gauss_3=gauss_3/sum(gauss_3(:));
%对R通道操作
Ir_log=log(Ir_double+1); %将图像转换到对数域
%sigam=20的处理结果
G1=conv2(Ir_doubleGauss_1‘same‘);
Rr_log=log(G1+1);
Rr1=Ir_log-Rr_log;
%sigam=80
G2=conv2(Ir_doubleGauss_2‘same‘);
Rr_log=log(G2+1);
Rr2=Ir_log-Rr_log;
%sigam=300
G3=conv2(Ir_doubleGauss_3‘same‘);
Rr_log=log(G3+1);
Rr3=Ir_log-Rr_log;
%MSRCR
Rr=Rr1/3+Rr2/3+Rr3/3;
CRr = beta*(log(alpha*Ir_double+1)-log(Ir_double+Ig_double+Ib_double+1));
Rr = G*(CRr.*Rr+b);
min1 = min(min(Rr));
max1 = max(max(Rr));
Rr_final = uint8(255*(Rr-min1)/(max1-min1));
- 上一篇:单尺度Retinex算法实现
- 下一篇:gabor滤波的matlab实现
评论
共有 条评论