単一画像に基づく高速霧除去アルゴリズム

1060 ワード

本論文は清華大学が書いた平均フィルタリングに基づくミスト除去アルゴリズムである.
%              
fileName = 'D:\\image\\haze image\\He\\canon3.bmp';

% step1:   :    H(x)
H = imread(fileName);
H = double(H) / 255.0;
imtool(H);
[h, w] = size(H);
sv = ceil(max(h, w) / 50);
if mod(sv, 2) == 0
    sv = sv + 1;
end

% step2:   H(x)       M(x)
M = min(H, [], 3);

% step3:  M(x)      ,  Mave(x)

f = fspecial('average', sv);
Mave = imfilter(M, f, 'symmetric');   

% step4:   M(x)        Mav
[h, w] = size(Mave);
n = 0.0;
for i=1:h
    for j=1:w
        n = n + Mave(i, j);  
    end
end
Mav = n / (h * w);

% step5:   Mave(x)  L(x)
e = 2.0;    % e          , e    ,         ,        ,e    ,    ,      。
L = min(min(e*Mav, 0.9)*Mave, M);


% step6:   Mave(x) H(x),  A
temp = max(H, [], 3);
A = 0.5 * (max(temp(:)) + max(Mave(:))) * [1; 1; 1];

% step7:      F(x)
[h, w, c] = size(H);
F = zeros(h, w, c);
for i=1:h
    for j=1:w
        for k=1:c
            F(i,j,k) = (H(i,j,k) - L(i,j)) / (1 - L(i,j)/A(k));
        end
    end
end

imtool(F);