资源简介
带色彩恢复的多尺度Retinex算法(MSRCR),可运行
代码片段和文件信息
%%%%%%%% multiple scales retinex %%%%%%%
clc;
clear all;
I=imread(‘c:\matlab\work\images\nighttime images\8.png‘);
Ir=I(::1); %分别提取图像的R分量G分量和B分量
Ig=I(::2);
Ib=I(::3);
%%%%%%%%%%设定所需参数%%%%%%
G = 192;
b = -30;
alpha = 125;
beta = 46;
Ir_double=double(Ir);
Ig_double=double(Ig);
Ib_double=double(Ib);
%%%%%%%%%%设定高斯参数%%%%%%
sigma_1=15; %三个高斯核
sigma_2=80;
sigma_3=250;
[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分量操作%%%%%%%
% MSR部分
Ir_double=double(Ir);
Ir_log=log(Ir_double+1); %将图像转换到对数域
f_Ir=fft2(Ir_double); %对图像进行傅立叶变换转换到频域中
fgauss=fft2(Gauss_1size(Ir1)size(Ir2));
fgauss=fftshift(fgauss); %将频域中心移到零点
Rr=ifft2(fgauss.*f_Ir); %做卷积后变换回空域中
min1=min(min(Rr));
Rr_log= log(Rr - min1+1);
Rr1=Ir_log-Rr_log; %sigam=15的处理结果
fgauss=fft2(Gauss_2size(Ir1)size(Ir2));
fgauss=fftshift(fgauss);
Rr= ifft2(fgauss.*f_Ir);
min1=min(min(Rr));
Rr_log= log(Rr - min1+1);
Rr2=Ir_log-Rr_log; %sigam=80
fgauss=fft2(Gauss_3size(Ir1)size(Ir2));
fgauss=fftshift(fgauss);
Rr= ifft2(fgauss.*f_Ir);
min1=min(min(Rr));
Rr_log= log(Rr - min1+1);
Rr3=Ir_log-Rr_log; %sigam=250
Rr=0.33*Rr1+0.34*Rr2+0.33*Rr3; %加权求和
%计算CR
CRr = beta*(log(alpha*Ir_double+1)-log(Ir_double+Ig_double+Ib_double+1));
%MSRCR
Rr = G*CRr.*Rr+b;
% min1 = min(min(Rr));
% max1 = max(max(Rr));
% Rr_final = (Rr-min1)/(max1-min1);
Rr_final = mat2gray(Rr);
%figureimshow(Rr_final);
%%%%%%%%%%对g分量操作%%%%%%%
% MSR部分
Ig_double=double(Ig);
Ig_log=log(Ig_double+1); %将图像转换到对数域
f_Ig=fft2(Ig_double); %对图像进行傅立叶变换转换到频域中
fgauss=fft2(Gauss_1s
- 上一篇:PCA故障检测MATLAB
- 下一篇:LLC simuli
nk仿真
评论
共有 条评论