✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
小波分析是当前数学中一个迅速发展的新领域,在Matlab中,图像的增强,除噪,压缩是其应用领域中的一个方面.文中首先介绍了小波分析的历史与现状,然后详细地说明了当前小波分析在图像方面的各个应用领域和研究的意义,以及其研究工具Matlab组成和特点,从理论上讲解了小波变换的由来,定义和特点,在分析中所涉及到的连续小波变换,离散小波变换,二维小波变换.通过小波分析的理论研究,应用Matlab来实现了一般图像的压缩,除噪和增强,然后利用小波分析的工具箱打开图形接口方式,来实现相关小波分析的应用.由于小波分析在图像中有许多的优点,因此小波分析在各个应用领域也越来越广.
⛄ 部分代码
function varargout = waveletgui(varargin)
% WAVELETGUI MATLAB code for waveletgui.fig
% WAVELETGUI, by itself, creates a new WAVELETGUI or raises the existing
% singleton*.
%
% H = WAVELETGUI returns the handle to a new WAVELETGUI or the handle to
% the existing singleton*.
%
% WAVELETGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WAVELETGUI.M with the given input arguments.
%
% WAVELETGUI('Property','Value',...) creates a new WAVELETGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before waveletgui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to waveletgui_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 waveletgui
% Last Modified by GUIDE v2.5 25-Dec-2022 00:20:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @waveletgui_OpeningFcn, ...
'gui_OutputFcn', @waveletgui_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 waveletgui is made visible.
function waveletgui_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 waveletgui (see VARARGIN)
% Choose default command line output for waveletgui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes waveletgui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = waveletgui_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)
global im
global cmap
%选择图片路径
[filename, pathname] = ...
uigetfile({'*.jpg';'*.bmp';'*.gif'},'选择图片');
%合成路径+文件名
str = [pathname, filename];
%读取图片
[im,cmap] = imread(str);
%使用第一个axes
axes(handles.axes1);
%显示图片
imshow(im);
% --- 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)
close(gcf)
% --- 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)
global im
global cmap
global wavename
X = im;
map = cmap;
% X contains the loaded image.
% map contains the loaded colormap.
nbcol = size(map,1);
% Perform single-level decomposition
% of X using db1.
[cA1,cH1,cV1,cD1] = dwt2(X,wavename);
% Images coding.
cod_X = wcodemat(X,nbcol);
cod_cA1 = wcodemat(cA1,nbcol);
cod_cH1 = wcodemat(cH1,nbcol);
cod_cV1 = wcodemat(cV1,nbcol);
cod_cD1 = wcodemat(cD1,nbcol);
⛄ 运行结果
⛄ 参考文献
[1]刘鹏远, 骆升平. Matlab基于小波变换的图形图像处理[J]. 江西理工大学学报, 2011, 32(1):3.