• 大小: 4KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: Matlab
  • 标签: 图像去雾  

资源简介

图像去雾算法

资源截图

代码片段和文件信息

clc;
clear all;
img_name=‘jiedao.jpg‘;
% 原始图像
I=double(imread(img_name))/255;
% 获取图像大小
[hwc]=size(I);
win_size = 7;
img_size=w*h;
figure imshow(I);
win_dark=ones(hw);
%计算分块darkchannel
 for j=1+win_size:w-win_size
    for i=win_size+1:h-win_size
        m_pos_min = min(I(ij:));
        for n=j-win_size:j+win_size
            for m=i-win_size:i+win_size
                if(win_dark(mn)>m_pos_min)
                    win_dark(mn)=m_pos_min;
                end
            end
        end
    end
 end
 %选定精确dark value坐标
% win_b = zeros(img_size1);
 figure imshow(win_dark);
 win_t=1-0.95*win_dark;
 win_b=zeros(img_size1);
for ci=1:h
    for cj=1:w
        if(rem(ci-815)<1)
            if(rem(cj-815)<1)
                win_b(ci*w+cj)=win_t(ci*w+cj);
            end
        end
    end
end
 
%显示分块darkchannel
%figure imshow(win_dark);
neb_size = 9;
win_size = 1;
epsilon = 0.000001;
%指定矩阵形状
indsM=reshape(1:img_sizehw);
%计算矩阵L
tlen = img_size*neb_size^2;
row_inds=zeros(tlen 1);
col_inds=zeros(tlen1);
vals=zeros(tlen1);
len=0;
for j=1+win_size:w-win_size
    for i=win_size+1:h-win_size
        if(rem(h-815)<1)
            if(rem(w-815)<1)
                continue;
            end
        end
      win_inds=indsM(i-win_size:i+win_sizej-win_size:j+win_size);
      win_inds=win_inds(:);%列显示
      winI=I(i-win_size:i+win_sizej-win_size:j+win_size:);
      winI=reshape(winIneb_sizec); %三个通道被拉平成为一个二维矩阵 9*3
      win_mu=mean(winI1)‘;  %求每一列的均值 如果第二个参数为2 则为求每一行的均值  //矩阵变向量
      win_var=winI‘*winI/neb_size-win_mu*win_mu‘+epsilon/neb_size*eye(c); %求方差
      winI=winI-repmat(win_mu‘neb_size1);%求离差
      tvals=(1+winI/win_var*winI‘)/neb_size;% 求论文所指的矩阵L
      row_inds(1+len:neb_size^2+len)=reshape(repmat(win_inds1neb_size)...
      

评论

共有 条评论