一、简介
1 课题背景
雾,在很大程度上会降低能见度,因此在此情况下拍摄的图像对比度也会受到严重的影响。尤其是在智能化的今天,对于交通领域的影响表现的尤为明显。因此,找到应对这种自然现象造成的图像对比度减弱问题的解决办法对于整个领域的发展是非常有现实意义的。
近年来,随着互联网技术的不断发展,关于图像处理方面的技术也趋于成熟,特别是在户外视觉方面的进步也尤为突出。其已经不仅仅局限在户外,在其他领域也有所涉及。MATLAB本身具有非常强大的图像处理功能,通过仔细调研发现其能够将在恶劣天气条件下拍摄的图像进行处理,进一步提高图像对比度以接近于原始图像。本次研究主要使用暗通道先验算法对图像进行去雾处理,这种算法不仅仅适用于由于恶劣天气造成的图像对比度降低的情况,其对于处理其他对比度较低的图像也是非常有帮助的。
2 暗通道
上述伪代码中,I表示导向图像(guided image),p为输入图像(input image),q为输出图像(output image),表示均值滤波,r为窗口半径。
二、源代码
unction varargout = zhongzhiquwu(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @zhongzhiquwu_OpeningFcn, ...
'gui_OutputFcn', @zhongzhiquwu_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before zhongzhiquwu is made visible.
function zhongzhiquwu_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to zhongzhiquwu (see VARARGIN)
axes(handles.axes1);
imshow([255]);
axes(handles.axes2);
imshow([255]);
axes(handles.axes3);
imshow([255]);
axes(handles.axes4);
imshow([255]);
axes(handles.axes5);
imshow([255]);
% Choose default command line output for zhongzhiquwu
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes zhongzhiquwu wait for user response (see UIRESUME)
% uiwait(handles.figure1);
%
% --- Outputs from this function are returned to the command line.
function varargout = zhongzhiquwu_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
global b
global dark_I2
global dark_I
global T
global J
axes(handles.axes1);
imshow([255]);
axes(handles.axes2);
imshow([255]);
axes(handles.axes3);
imshow([255]);
axes(handles.axes4);
imshow([255]);
axes(handles.axes5);
imshow([255]);
axes(handles.axes1)
[filename,pathname]=uigetfile({ ...
'*.*','All Files(*.*)';},...
'选择文件');
%
if isequal([filename,pathname],[0,0])
return
else
%读取图片
pic = fullfile(pathname,filename);
b = imread(pic);
imshow(b);%上面是打开图片的步骤,这一句是显示图片
title('原始图片');
[dark_I2,dark_I,T,J]=min_quwu(b);
%handle.axes1=b;
end
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
global dark_I2
axes(handles.axes2);
imshow(dark_I2);
title('估算得到的雾浓度');
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
global dark_I
axes(handles.axes3);
imshow(dark_I);
title('中值滤波对雾浓度的修正');
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
global T
axes(handles.axes4);
imshow(T);
title('透视率分布图');
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
global J
axes(handles.axes5);
imshow(J);
title('去雾图像');
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
global dark_I2
axes(handles.axes2);
imshow(dark_I2);
title('估算得到的物浓度');
global dark_I
axes(handles.axes3);
imshow(dark_I);
title('中值滤波对雾浓度的修正');
global T
axes(handles.axes4);
imshow(T);
title('透视率分布图');
global J
axes(handles.axes5);
imshow(J);
title('去雾图像');
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
三、运行结果
四、备注
版本:2014a
需要完整代码或代写加QQ 1564658423