• 大小: 1KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: 其他
  • 标签: retinex  图像  去雾  

资源简介

该算法是基于retinex理论的,在图像去雾上取得了很好的成果,基本和何凯明的暗通道去雾算法相媲美

资源截图

代码片段和文件信息

clear
clc
tic
%*****************参数***********
k1=225;
k2=3000; 
k3=80000;
k4=10000;
r=81;
c = 0.01;
nn=floor((r+1)/2);   % 计算中心
% nn=0;

string = ‘night3‘;
string1 = [string ‘.bmp‘];
I = imread(string1);
subplot(131);
imshow(I);

f=I(::1);
ff=I(::2);
fff=I(::3);
Img1 = double(f);
Img2 = double(ff);
Img3 = double(fff);
[mn]=size(f);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
b = zeros(rr);
bb = zeros(rr);
bbb = zeros(rr);

for i=1:r
    for j=1:r
        b(ij) =exp(-((i-nn)^2+(j-nn)^2)/k1)/k4;        %高斯函数1
   end
end
tiaojie1 = 1/sum(sum(b));
b = tiaojie1.*b;

for i=1:r
    for j=1:r
        bb(ij) =exp(-((i-nn)^2+(j-nn)^2)/k2)/k4;       %高斯函数2
   end
end
tiaojie2 = 1/sum(sum(bb));
bb = tiaojie2.*bb;
for i=1:r
    for j=1:r
        bbb(ij) =exp(-((i-nn)^2+(j-nn)^2)/k3)/k4;      %高斯函数3
   end
end
tiaojie3 = 1/sum(sum(bbb));
bbb = tiaojie3.*bbb;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%对R分量的处理%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
K=imfilter(Img1b);
KK=imfilter(Img1bb);
KKK=imfilter(Img1bbb);

G = zeros(mn);
for i=1:m
    for j=1:n      
       G(ij)=1/3*(log(Img1(ij)+c)-log(K(ij)+c));
        G(ij)=1/3*(log(Img1(ij)+c)-log(KK(ij)+c))+G(ij);
         G(ij)=1/3*(log(Img1(ij)+c)-log(KKK(ij)+c))+G(ij);
    end
end
G = 3*G+50;
mi=min(min(G));
ma=max(max(G));
L=(G-mi)*255/(ma-mi);
%%%%%%%%%%%%%%对G分量的处理%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
K=imfilter(Img2b);
KK=imfilter(Img2bb);
KKK=imfilter(Img2bbb);

for i=1:m
    for j=1:n      
       G(ij)=1/3*(log(Img2(ij)+c)-log(K(ij)+c));
        G(ij)=1/3*(log(Img2(ij)+c)-log(KK(ij)+c))+G(ij);
         G(ij)=1/3*(log(Img2(ij)+c)-log(KKK(ij)+c))+G(ij);
    end
end
G = 3*G+50;
mi=min(min(G));
ma=max(max(G));
LL=(G-mi)*255/(ma-mi);
%%%%%%%%%%%%%随B分量的处理%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
K=imfilter(Img3b);
KK=imfilter(Img3bb);
KKK=imfilter(Img3bbb);

for i=1:m
    for j=1:n      
       G(ij)=1/3*(log(Img3(ij)+c)-log(K(ij)+c));
        G(ij)=1/3*(log(Img3(ij)+c)-log(KK(ij)+c))+G(ij);
         G(ij)=1/3*(log(Img3(ij)+c)-log(KKK(ij)+c))+G(ij);
    end
end
G = 3*G+50;
mi=min(min(G));
ma=max(max(G));
LLL=(G-mi)*255/(ma-mi);
%%%%%%%%%%%%对彩色图像的综合处理 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I(::1)= L;
I1 = adapthisteq(I(::1));
I(::2)= LL;
I2 = adapthisteq(I(::2));
I(::3)= LLL;
I3 = adapthisteq(I(::3));
msr1 = cat(3LLLLLL);
msr2 = cat(3I1I2I3);

subplot(132);
imshow(uint8(msr1));
subplot(133);
imshow(uint8(msr2));
string2 = [string ‘result.jpg‘];
imwrite(uint8(msr2)string2);
toc

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-03-04 22:10  retinex\
     文件        2684  2011-03-03 14:52  retinex\retinex.m

评论

共有 条评论