在图像处理过程中,图像噪声对图像的后续处理和清晰度影响较大.因此,对图像的降噪至关重要.随着小波变换的不断优化,小波变换广泛应用在图像降噪方面.该文基于软阈值的小波图像增强方法,通过实验论述小波变换在图像去噪中的应用.
function varargout = wavelet(varargin)
% WAVELET MATLAB code for wavelet.fig
% WAVELET, by itself, creates a new WAVELET or raises the existing
% singleton*.
%
% H = WAVELET returns the handle to a new WAVELET or the handle to
% the existing singleton*.
%
% WAVELET('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in WAVELET.M with the given input arguments.
%
% WAVELET('Property','Value',...) creates a new WAVELET or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before wavelet_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to wavelet_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 wavelet
% Last Modified by GUIDE v2.5 10-Jan-2021 05:42:48
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @wavelet_OpeningFcn, ...
'gui_OutputFcn', @wavelet_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 wavelet is made visible.
function wavelet_OpeningFcn(hObject, eventdata, handles, varargin)
%**********************************************************************%
% 五、重构
%**********************************************************************%
CA_Temp = RanksInterpolation(newCA,'r',2);
CH_Temp = RanksInterpolation(newCH,'r',2);
CloumnTemp1 = RanksConv(CA_Temp,Lo_R,'c')+RanksConv(CH_Temp,Hi_R,'c');
CV_Temp = RanksInterpolation(newCV,'r',2);
CD_Temp = RanksInterpolation(newCD,'r',2);
CloumnTemp2 = RanksConv(CV_Temp,Lo_R,'c')+RanksConv(CD_Temp,Hi_R,'c');
CloumnTempA = RanksInterpolation(CloumnTemp1,'c',2);
CloumnTempB = RanksInterpolation(CloumnTemp2,'c',2);
RowTemp = RanksConv(CloumnTempA,Lo_R,'r')+RanksConv(CloumnTempB,Hi_R,'r');
Image_R =wkeep(RowTemp,size(HANDDLE_IMAGE),'c'); %提取向量和矩阵的部分
axes(handles.axes_worked);
image (Image_R)
setappdata(handles.figure_wavelet,'Image_R',Image_R);
%HANDDLE_IMAGE = img_src; %为避免后续程序中误用X故用自定义变量替代
%image(HANDDLE_IMAGE);
% imshow(X); %用imread读入图片,并用imshow在axes_src上显示
% WAVELET_NAME = 'sym8';
%[Lo_D,Hi_D,Lo_R,Hi_R]=wfilters(WAVELET_NAME);
%RowLo_DTemp = RanksSampling(RanksConv(HANDDLE_IMAGE,Lo_D,'r'),'c',2);
%CA = RanksSampling(RanksConv(RowLo_DTemp,Lo_D,'c'),'r',2);
%subplot(221);image(CA);colormap(map);title('Lo_D低通分解后的图像CA')%画出CA的图像
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes on selection change in wavelet_style.
function wavelet_style_Callback(hObject, eventdata, handles)
% hObject handle to wavelet_style (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns wavelet_style contents as cell array
% contents{get(hObject,'Value')} returns selected item from wavelet_style
WAVELET_NAME = 'haar';
val = get(handles.wavelet_style,'Value'); %获取下拉框的值
switch val %选择小波
case 1
WAVELET_NAME = 'haar'
case 2
WAVELET_NAME = 'db2';
case 3
WAVELET_NAME = 'db4';
case 4
WAVELET_NAME = 'db6';
case 5
WAVELET_NAME = 'db8';
case 6
WAVELET_NAME = 'db10';
case 7
WAVELET_NAME = 'sym2';
case 8
WAVELET_NAME = 'sym4';
case 9
WAVELET_NAME = 'sym6';
case 10
WAVELET_NAME = 'sym8';
case 11
WAVELET_NAME = 'sym10';
case 12
WAVELET_NAME = 'coif1';
case 13
WAVELET_NAME = 'coif3';
case 14
WAVELET_NAME = 'coif5';
case 15
WAVELET_NAME = 'dmey'
case 16
WAVELET_NAME = 'haar'
end
setappdata(handles.figure_wavelet,'WAVELET_NAME',WAVELET_NAME);
% --- Executes during object creation, after setting all properties.
function wavelet_style_CreateFcn(hObject, eventdata, handles)
% hObject handle to wavelet_style (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in filter_style.
function filter_style_Callback(hObject, eventdata, handles)
% hObject handle to filter_style (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns filter_style contents as cell array
% contents{get(hObject,'Value')} returns selected item from filter_style
Filter_style = get(handles.filter_style,'Value');
setappdata(handles.figure_wavelet,'Filter_style',Filter_style);
% --- Executes during object creation, after setting all properties.
function filter_style_CreateFcn(hObject, eventdata, handles)
% hObject handle to filter_style (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --------------------------------------------------------------------
function m_thanks_Callback(hObject, eventdata, handles)
% hObject handle to m_thanks (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h = thanks;
% --------------------------------------------------------------------
function m_about_Callback(hObject, eventdata, handles)
% hObject handle to m_about (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h = about;
% --------------------------------------------------------------------
function m_file_Callback(hObject, eventdata, handles)
% hObject handle to m_file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function m_file_open_Callback(hObject, eventdata, handles)
% hObject handle to m_file_open (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( ...
{'*.bmp;*,jpg;*.png;*.jpeg;*.tif','Image File(*.bmp,*.jpg,*.png,*jpeg,*.tif)';...
'*.*', 'All File(*.*)'},...
'Pick an image');
axes(handles.axes_original); %用axes命令设定当前操作的坐标轴是axes_src
fpath = [pathname filename]; %将文件名和目录名组合成一个完整的路径
img_src = imread(fpath);
imshow(img_src); %用imread读入图片,并用imshow在axes_src上显示
setappdata(handles.figure_wavelet,'img_src',img_src);
% --------------------------------------------------------------------
function m_file_save_Callback(hObject, eventdata, handles)
% hObject handle to m_file_save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uiputfile({'*.bmp','BMP files';'*.jpg;','JPG files'},'Pick an Image');
if isequal(filename,0) || isequal(pathname,0)
return; %如果点了“取消”
else
fpath = fullfile(pathname,filename);
end
Image_R = getappdata(handles.figure_wavelet,'Image_R');
imwrite(Image_R,fpath);
% --------------------------------------------------------------------
function m_file_exit_Callback(hObject, eventdata, handles)
% hObject handle to m_file_exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close;
[1]张俊, & 朱凯荣. (2011). 基于matlab软件的小波变换在图像去噪中的应用. 电脑知识与技术(9X), 1.
部分理论引用网络文献,若有侵权联系博主删除。