【影象融合】基於matlab GUI小波變換影象融合【含Matlab原始碼 700期】
一、簡介
1974年,法國工程師J.Morlet首先提出小波變換的概念,1986年著名數學家Y.Meyer偶然構造出一個真正的小波基,並與S.Mallat合作建立了構造小波基的多尺度分析之後,小波分析才開始蓬勃發展起來。小波分析的應用領域十分廣泛,在數學方面,它已用於數值分析、構造快速數值方法、曲線曲面構造、微分方程求解、控制論等。在訊號分析方面的濾波、去噪聲、壓縮、傳遞等。在影象處理方面的影象壓縮、分類、識別與診斷,去噪聲等。本章將著重闡述小波在影象中的應用分析。
1 小波變換原理
小波分析是一個比較難的分支,使用者採用小波變換,可以實現影象壓縮,振動訊號的分解與重構等,因此在實際工程上應用較廣泛。小波分析與Fourier變換相比,小波變換是空間域和頻率域的區域性變換,因而能有效地從訊號中提取資訊。小波變換通過伸縮和平移等基本運算,實現對訊號的多尺度分解與重構,從而很大程度上解決了Fourier變換帶來的很多難題。
小波分析作一個新的數學分支,它是泛函分析、Fourier分析、數值分析的完美結晶;小波分析也是一種“時間—尺度”分析和多分辨分析的新技術,它在訊號分析、語音合成、影象壓縮與識別、大氣與海洋波分析等方面的研究,都有廣泛的應用。
(1)小波分析用於訊號與影象壓縮。小波壓縮的特點是壓縮比高,壓縮速度快,壓縮後能保持訊號與影象的特徵不變,且在傳遞中能夠抗干擾。基於小波分析的壓縮方法很多,具體有小波壓縮,小波包壓縮,小波變換向量壓縮等。
(2)小波也可以用於訊號的濾波去噪、訊號的時頻分析、信噪分離與提取弱訊號、求分形指數、訊號的識別與診斷以及多尺度邊緣檢測等。
(3)小波分析在工程技術等方面的應用概括的包括計算機視覺、曲線設計、湍流、遠端宇宙的研究與生物醫學方面。
2 多尺度分析
3 影象的分解和量化
4 影象壓縮編碼
5 影象編碼評價
二、原始碼
function varargout = MainForm(varargin) % MAINFORM MATLAB code for MainForm.fig % MAINFORM, by itself, creates a new MAINFORM or raises the existing % singleton*. % % H = MAINFORM returns the handle to a new MAINFORM or the handle to % the existing singleton*. % % MAINFORM('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MAINFORM.M with the given input arguments. % % MAINFORM('Property','Value',...) creates a new MAINFORM or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before MainForm_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to MainForm_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help MainForm % Last Modified by GUIDE v2.5 22-Dec-2013 09:58:50 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @MainForm_OpeningFcn, ... 'gui_OutputFcn', @MainForm_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 MainForm is made visible. function MainForm_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 MainForm (see VARARGIN) % Choose default command line output for MainForm handles.output = hObject; clc; axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', '', 'YTickLabel', ''); axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', '', 'YTickLabel', ''); axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', '', 'YTickLabel', ''); % Update handles structure guidata(hObject, handles); % UIWAIT makes MainForm wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = MainForm_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) % 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) clc; axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', '', 'YTickLabel', ''); axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', '', 'YTickLabel', ''); axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', '', 'YTickLabel', ''); handles.file1 = []; handles.file2 = []; handles.result = []; [filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif', 'All Image Files';... '*.*', 'All Files' }, '選擇影象1', ... fullfile(pwd, 'images\\實驗影象1\\a.tif')); if isequal(filename, 0) return; end handles.file1 = fullfile(pathname, filename); guidata(hObject, handles); Img1 = imread(fullfile(pathname, filename)); axes(handles.axes1); imshow(Img1, []); % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % 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) [filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif', 'All Image Files';... '*.*', 'All Files' }, '選擇影象2', ... fullfile(pwd, 'images\\實驗影象1\\b.tif')); if isequal(filename, 0) return; end handles.file2 = fullfile(pathname, filename); guidata(hObject, handles); Img2 = imread(fullfile(pathname, filename)); axes(handles.axes2); imshow(Img2, []); % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % 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) if isempty(handles.file1) msgbox('請載入影象1!', '提示資訊', 'modal'); return; end if isempty(handles.file2) msgbox('請載入影象2!', '提示資訊', 'modal'); return; end [imA, map1] = imread(handles.file1); [imB, map2] = imread(handles.file2); M1 = double(imA) / 256; M2 = double(imB) / 256; zt = 2; wtype = 'haar'; [c0, s0] = Wave_Decompose(M1, zt, wtype); [c1, s1] = Wave_Decompose(M2, zt, wtype); Y = Wave_Reconstruct(Coef_Fusion, s0, wtype); handles.result = im2uint8(mat2gray(Y)); guidata(hObject, handles); msgbox('小波融合處理完畢!', '提示資訊', 'modal'); % --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % 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) if isempty(handles.result) msgbox('請進行填充處理!', '提示資訊', 'modal'); return; end function [c, s] = Wave_Decompose(M, zt, wtype) if nargin < 3 wtype = 'haar'; end if nargin < 2 zt = 2; end
三、執行結果
四、備註
版本:2014a
完整程式碼或代寫加1564658423