function res123 = Code(arg)
close all;
clc;
I=imread(arg);
Ir=I(:,:,1);
Ig=I(:,:,2);
Ib=I(:,:,3);
%%%%%%%%%%Set the required parameters%%%%%%
G = 192;
b = -30;
alpha = 125;
beta = 46;
Ir_double=double(Ir);
Ig_double=double(Ig);
Ib_double=double(Ib);
%%%%%%%%%%Set the Gaussian parameter%%%%%%
sigma_1=15; %Three Gaussian Kernels
sigma_2=80;
sigma_3=250;
[x, y]=meshgrid((-(size(Ir,2)-1)/2):(size(Ir,2)/2),(-(size(Ir,1)-1)/2):(size(Ir,1)/2));
gauss_1=exp(-(x.^2+y.^2)/(2*sigma_1*sigma_1)); %Calculate the Gaussian function
Gauss_1=gauss_1/sum(gauss_1(:)); %Normalization
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(:));
%%%%%%%%%%Operates on R component%%%%%%%
% MSR Section
Ir_log=log(Ir_double+1); %Converts an image to a logarithm field
f_Ir=fft2(Ir_double); %The image is Fourier transformed and converted to the frequency domain
%sigma = 15 processing results
fgauss=fft2(Gauss_1,size(Ir,1),size(Ir,2));
fgauss=fftshift(fgauss); %Move the center of the frequency domain to zero
Rr=ifft2(fgauss.*f_Ir); %After convoluting, transform back into the airspace
min1=min(min(Rr));
Rr_log= log(Rr - min1+1);
Rr1=Ir_log-Rr_log;
%sigma=80
fgauss=fft2(Gauss_2,size(Ir,1),size(Ir,2));
fgauss=fftshift(fgauss);
Rr= ifft2(fgauss.*f_Ir);
min1=min(min(Rr));
Rr_log= log(Rr - min1+1);
Rr2=Ir_log-Rr_log;
%sigma=250
fgauss=fft2(Gauss_3,size(Ir,1),size(Ir,2));
fgauss=fftshift(fgauss);
Rr= ifft2(fgauss.*f_Ir);
min1=min(min(Rr));
Rr_log= log(Rr - min1+1);
Rr3=Ir_log-Rr_log;
Rr=0.33*Rr1+0.34*Rr2+0.33*Rr3; %Weighted summation
MSR1 = Rr;
SSR1 = Rr2;
%Calculate CR
CRr = beta*(log(alpha*Ir_double+1)-log(Ir_double+Ig_double+Ib_double+1));
%SSR
min1 = min(min(SSR1));
max1 = max(max(SSR1));
SSR1 = uint8(255*(SSR1-min1)/(max1-min1));
%MSR
min1 = min(min(MSR1));
max1 = max(max(MSR1));
MSR1 = uint8(255*(MSR1-min1)/(max1-min1));
%MSRCR
Rr = G*(CRr.*Rr+b);
min1 = min(min(Rr));
max1 = max(max(Rr));
Rr_final = uint8(255*(Rr-min1)/(max1-min1));
%%%%%%%%%%On g component operation%%%%%%%
%Ig_double=double(Ig);
Ig_log=log(Ig_double+1); %Converts an image to a logarithm field
f_Ig=fft2(Ig_double); %The image is Fourier transformed and converted to the frequency domain
fgauss=fft2(Gauss_1,size(Ig,1),size(Ig,2));
fgauss=fftshift(fgauss); %Move the center of the frequency domain to zero
Rg= ifft2(fgauss.*f_Ig); %After convoluting, transform back into the airspace
min2=min(min(Rg));
Rg_log= log(Rg-min2+1);
Rg1=Ig_log-Rg_log; %sigma = 15 processing results
fgauss=fft2(Gauss_2,size(Ig,1),size(Ig,2));
fgauss=fftshift(fgauss);
Rg= ifft2(fgauss.*f_Ig);
min2=min(min(Rg));
Rg_log= log(Rg-min2+1);
Rg2=Ig_log-Rg_log; %sigma=80
fgauss=fft2(Gauss_3,size(Ig,1),size(Ig,2));
fgauss=fftshift(fgauss);
Rg= ifft2(fgauss.*f_Ig);
min2=min(min(Rg));
Rg_log= log(Rg-min2+1);
Rg3=Ig_log-Rg_log; %sigma=250
Rg=0.33*Rg1+0.34*Rg2+0.33*Rg3; %Weighted summation
SSR2 = Rg2;
MSR2 = Rg;
%Calculate CR
CRg = beta*(log(alpha*Ig_double+1)-log(Ir_double+Ig_double+Ib_double+1));
%SSR:
min2 = min(min(SSR2));
max2 = max(max(SSR2));
SSR2 = uint8(255*(SSR2-min2)/(max2-min2));
%MSR
min2 = min(min(MSR2));
max2 = max(max(MSR2));
MSR2 = uint8(255*(MSR2-min2)/(max2-min2));
%MSRCR
Rg = G*(CRg.*Rg+b);
min2 = min(min(Rg));
max2 = max(max(Rg));
Rg_final = uint8(255*(Rg-min2)/(max2-min2));
%%%%%%%%%%The B component is manipulated with the R component%%%%%%%
%Ib_double=double(Ib);
Ib_log=log(Ib_double+1);
f_Ib=fft2(Ib_double);
fgauss=fft2(Gauss_1,size(Ib,1),size(Ib,2));
fgauss=fftshift(fgauss);
Rb= ifft2(fgauss.*f_Ib);
min3=min(min(Rb));
Rb_log= log(Rb-min3+1);
Rb1=Ib_log-Rb_log;
fgauss=fft2(Gauss_2,size(Ib,1),size(Ib,2));
fgauss=fftshift(fgauss);
Rb= ifft2(fgauss.*f_Ib);
min3=min(min(Rb));
Rb_log= log(Rb-min3+1);
Rb2=Ib_log-Rb_log;
fgauss=fft2(Gauss_3,size(Ib,1),size(Ib,2));
fgauss=fftshift(fgauss);
Rb= ifft2(fgauss.*f_Ib);
min3=min(min(Rb));
Rb_log= log(Rb-min3+1);
Rb3=Ib_log-Rb_log;
Rb=0.33*Rb1+0.34*Rb2+0.33*Rb3;
%计算CR
CRb = beta*(log(alpha*Ib_double+1)-log(Ir_double+Ig_double+Ib_double+1));
SSR3 = Rb2;
MSR3 = Rb;
%SSR:
min3 = min(min(SSR3));
max3 = max(max(SSR3));
SSR3 = uint8(255*(SSR3-min3)/(max3-min3));
%MSR
min3 = min(min(MSR3));
max3 = max(max(MSR3));
MSR3 = uint8(255*(MSR3-min3)/(max3-min3));
%MSRCR
Rb = G*(CRb.*Rb+b);
min3 = min(min(Rb));
max3 = max(max(Rb));
Rb_final = uint8(255*(Rb-min3)/(max3-min3));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%MSRCP
Int = (Ir_double + Ig_double + Ib_double) / 3.0;
Int_log = log(Int+1); %Converts an image to a logarithm field
f_Int=fft2(Int_log); %The image is Fourier transformed and converted to the frequency domain
%sigma = 15 processing results
fgauss=fft2(Gauss_1,size(Int,1),size(Int,2));
fgauss=fftshift(fgauss); %Move the center of the frequency domain to zero
RInt=ifft2(fgauss.*f_Int); %After convoluting, transform back into the airspace
min1=min(min(RInt));
RInt_log= RInt - min1+1;
RInt1=Int_log-RInt_log;
%sigma=80
fgauss=fft2(Gauss_2,size(Int,1),size(Int,2));
fgauss=fftshift(fgauss);
RInt= ifft2(fgauss.*f_Int);
min1=min(min(RInt));
RInt_log= RInt - min1+1;
RInt2=Int_log-RInt_log;
%sigma=250
fgauss=fft2(Gauss_3,size(Int,1),size(Int,2));
fgauss=fftshift(fgauss);
RInt= ifft2(fgauss.*f_Int);
min1=min(min(RInt));
RInt_log= RInt - min1+1;
RInt3=Int_log-RInt_log;
RInt=0.33*RInt1+0.34*RInt2+0.33*RInt3; %Weighted summation
minInt = min(min(RInt));
maxInt = max(max(RInt));
Int1 = uint8(255*(RInt-minInt)/(maxInt-minInt));
MSRCPr = zeros(size(I, 1), size(I, 2));
MSRCPg = zeros(size(I, 1), size(I, 2));
MSRCPb = zeros(size(I, 1), size(I, 2));
for ii = 1 : size(I, 1)
for jj = 1 : size(I, 2)
C = max(Ig_double(ii, jj), Ib_double(ii, jj));
B = max(Ir_double(ii, jj), C);
A = min(255.0 / B, Int1(ii, jj) / Int(ii, jj));
MSRCPr(ii, jj) = A * Ir_double(ii, jj);
MSRCPg(ii, jj) = A * Ig_double(ii, jj);
MSRCPb(ii, jj) = A * Ib_double(ii, jj);
end
end
minInt = min(min(MSRCPr));
maxInt = max(max(MSRCPr));
MSRCPr = uint8(255*(MSRCPr-minInt)/(maxInt-minInt));
minInt = min(min(MSRCPg));
maxInt = max(max(MSRCPg));
MSRCPg = uint8(255*(MSRCPg-minInt)/(maxInt-minInt));
minInt = min(min(MSRCPb));
maxInt = max(max(MSRCPb));
MSRCPb = uint8(255*(MSRCPb-minInt)/(maxInt-minInt));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ssr = cat(3,SSR1,SSR2,SSR3);
msr = cat(3,MSR1,MSR2,MSR3);
msrcr=cat(3,Rr_final,Rg_final,Rb_final); %Combine the three-channel image
MSRCP = cat(3, MSRCPr, MSRCPg, MSRCPb);
subplot(3,2,1);imshow(I);title('Original') %Show the original image
subplot(3,2,2);imshow(ssr);title('SSR')
subplot(3,2,3);imshow(msr);title('MSR')
subplot(3,2,4);imshow(msrcr);title('MSRCR') %Displays the processed image
subplot(3,2,5);imshow(MSRCP);title('MSRCP')
没有合适的资源?快使用搜索试试~ 我知道了~
【图像增强】retinex图像增强(SSR,MSR.MSRCR,MSRCP)【含Matlab源码 4650期】.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共15个文件
jpg:8个
png:4个
m:2个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 112 浏览量
2024-06-07
08:02:30
上传
评论 1
收藏 4.05MB ZIP 举报
温馨提示
CSDN海神之光上传的代码均可运行,亲测可用,直接替换数据即可,适合小白; 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主或扫描博客文章底部QQ名片; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作 图像增强: 同态增晰图像增强、萤火虫算法图像增强、 图像去雾:直方图均衡化+Retinex理论图像去雾、暗通道图像去雾、偏振水下模糊图像去雾、双边滤波图像去雾、颜色衰减先验图像去雾
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 15 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/22c46cb7417b40989d92d67df86b9fff_tiqcmatlab.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
海神之光
- 粉丝: 4w+
- 资源: 2146
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)