【影象增強】基於matlab GUI暗通道影象去霧【含Matlab原始碼 740期】

語言: CN / TW / HK

一、簡介

1 課題背景\ 霧,在很大程度上會降低能見度,因此在此情況下拍攝的影象對比度也會受到嚴重的影響。尤其是在智慧化的今天,對於交通領域的影響表現的尤為明顯。因此,找到應對這種自然現象造成的影象對比度減弱問題的解決辦法對於整個領域的發展是非常有現實意義的。

近年來,隨著網際網路技術的不斷髮展,關於影象處理方面的技術也趨於成熟,特別是在戶外視覺方面的進步也尤為突出。其已經不僅僅侷限在戶外,在其他領域也有所涉及。MATLAB本身具有非常強大的影象處理功能,通過仔細調研發現其能夠將在惡劣天氣條件下拍攝的影象進行處理,進一步提高影象對比度以接近於原始影象。本次研究主要使用暗通道先驗演算法對影象進行去霧處理,這種演算法不僅僅適用於由於惡劣天氣造成的影象對比度降低的情況,其對於處理其他對比度較低的影象也是非常有幫助的。\ 2 暗通道\ 在這裡插入圖片描述\ 在這裡插入圖片描述\ 在這裡插入圖片描述\ 在這裡插入圖片描述\ 在這裡插入圖片描述\ 上述虛擬碼中,I表示導向影象(guided image),p為輸入影象(input image),q為輸出影象(output image),表示均值濾波,r為視窗半徑。

二、原始碼

```c 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

「其他文章」