您的位置:首页 > 其它

验证 Single Image Haze Rem…

2014-01-15 12:19 218 查看
原文地址:Single Image Haze Removal Using Dark Channel Prior先验的MATLAB代码">验证 Single Image Haze Removal Using Dark Channel Prior先验的MATLAB代码作者:bikey

图像处理 2010-07-02
16:27:10 阅读101 评论0 字号: 订阅

注:代码内容引自zixu1986 (Euro) 北邮人论坛
这个先验是:没有haze干扰自然景像中local
patches(除了蓝天)总有一些像素的某个通道值非常低。
引起的原因是

1)局部阴影

2)很多彩色在rgb3个通道中有些通道的值很低

3)暗的物体或者表面

% a script to see the dark
channels of each image

input_dir = 'banff';
block_size = 25;
file_ext = '.jpg';

% getting the filenames of the images
files = dir(input_dir);
filenames = {files.name};

for i = 1:length(filenames)
if
isempty(strfind(lower(filenames{i}), file_ext))

continue

end


disp('.')

read_filename = [input_dir filesep
filenames{i}];
I =
imread(read_filename);

img_size = size(I);
% must
be 3-channel color image
if
length(img_size) ~= 3 || img_size(3) ~= 3

% warning('Should be color
image!')

continue

end

% min
of each channel
tmp =
[];
for j =
1:3

tmp(:,:,j) =
uint8(colfilt(I(:,:,j), [block_size block_size], 'sliding',
@min));

end


dark_channel = uint8(min(tmp,[],3));

k =
strfind(lower(filenames{i}), file_ext);

orig_name = filenames{i};

orig_name = orig_name(1:k-1);

save_filename = [input_dir filesep orig_name 'dc'
int2str(block_size) file_ext];

imwrite(dark_channel, save_filename);

end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: