%img_name='P0002.png';
%I=imread(img_name);
% subplot(2,2,1);
%td = add_fog(I);
%imshow(td);
file_path = 'D:\paper\4dehaze_remotesensing\dataset\DOTA\train\images\'; % 图像文件夹路径
out_path = 'D:\paper\4dehaze_remotesensing\dataset\DOTA\train\images_foggy\';% 图像文件夹路径
img_path_list = dir(strcat(file_path, '*.png'));%获取该文件夹中所有bmp格式的图像
img_num = length(img_path_list);%获取图像总数量
I=cell(1,img_num);
if img_num > 0 %有满足条件的图像
for j = 1 : img_num %逐一读取图像
image_name = img_path_list(j).name;% 图像名
image = imread(strcat(file_path,image_name));
%I{j}=image;
Iw = add_fog(image);
fprintf('%d %d %s\n',i ,j,strcat(file_path,image_name));% 显示正在处理的图像名
imwrite(Iw, strcat(out_path,image_name))
%图像处理过程 省略
%这里直接可以访问细胞元数据的方式访问数据
end
end
function [Iw] = add_fog( I )
I1 = imresize(I,[512,512]);
I1=double(I1)/255;
I = I1;
% figure;imagesc(I); %一图
Im_dealt = I;
[row,col,z] = size(Im_dealt);
landline = 0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Iw = I;
A = 0.8;
m = 100;
n = 300;
tidx= 2;
for beta = 0.05:0.05:0.15
%for beta = 0.20:0.05:0.30
for i=1:3
for j=landline+1:row
for l=1:col
d(j,l) = 1/((j-landline)^.05 + 0.0001);
d2(j,l) = d(j,l)*8;
if j < landline
d(j,l) = -0.04*landline + 18;
td(j,l) = exp(-beta*d(j,l));
Iw(j,l,i) = I(landline,l,i)*td(landline,l) + A*(1-td(j,l));
else
d(j,l) = -0.04*sqrt((j-m).^2+(l-n).^2) + 17;
td(j,l) = exp(-beta*d(j,l));
Iw(j,l,i) = I(j,l,i)*td(j,l) + A*(1-td(j,l));
end
end
end
end
for k = 1:landline
for kj = 1:col
Iw(k,kj,: ) = Iw(landline+1,100,:);
end
end
%figure(tidx);
imshow(Iw);
filename = ['.\outPicture\frame179-',num2str(tidx),'.tif'];
%imwrite(Iw,filename);
%subplot(2,2,tidx); imshow(Iw);
%a = sprintf('%s %f','beta=',beta);
%title(a);
tidx = tidx+1;
end
end
% figure; imshow(d);
%figure; imshow(td);