【图像去噪】基于matlab GUI中值+小波+维纳+滤波器图像去噪【含Matlab源码 616期】

一、简介

基于matlab GUI中值、小波、维纳、滤波器图像滤波

二、源代码

function varargout = dsp1(varargin)
% DSP1 MATLAB code for dsp1.fig
%      DSP1, by itself, creates a new DSP1 or raises the existing
%      singleton*.
%
%      H = DSP1 returns the handle to a new DSP1 or the handle to
%      the existing singleton*.
%
%      DSP1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DSP1.M with the given input arguments.
%
%      DSP1('Property','Value',...) creates a new DSP1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before dsp1_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to dsp1_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 dsp1

% Last Modified by GUIDE v2.5 21-Mar-2014 21:34:03

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @dsp1_OpeningFcn, ...
                   'gui_OutputFcn',  @dsp1_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 dsp1 is made visible.
function dsp1_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 dsp1 (see VARARGIN)
setappdata(handles.figure1,'img1',0);
setappdata(handles.figure1,'img2',0);
setappdata(handles.figure1,'img3',0);
%set(handles.myimage_compress,'Enable', 'off');
set(handles.pushbutton_compress,'Enable', 'off');
set(handles.menu_quzaodesc, 'Enable', 'off');
set(handles.save, 'Enable', 'off');


% Choose default command line output for dsp1
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes dsp1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = dsp1_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 selection change in popupmenu.
function popupmenu_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu (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 popupmenu contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu
val = get(hObject,'Value');
str = get(hObject, 'String');
switch str{val};
case '无' % 
	img2=getappdata(handles.figure1,'img1');
    axes(handles.axes2);
    imshow(img2);
    setappdata(handles.figure1,'img2',img2);
    set(handles.pushbutton_listen, 'Enable', 'off');
case '高斯噪声' % 
	img2=getappdata(handles.figure1,'img1');
    img2 = imnoise(img2,'gaussian'); %加高斯噪声
    axes(handles.axes2);
    imshow(img2);
    setappdata(handles.figure1,'img2',img2);
    set(handles.menu_quzaodesc, 'Enable', 'on');
    set(handles.pushbutton_listen, 'Enable', 'on');
case '椒盐噪声' % 
	img2=getappdata(handles.figure1,'img1');
    img2 = imnoise(img2,'salt');
    axes(handles.axes2);
    imshow(img2);
    setappdata(handles.figure1,'img2',img2);
    set(handles.menu_quzaodesc, 'Enable', 'on');
    set(handles.pushbutton_listen, 'Enable', 'on');
case '泊松噪声' % 
	img2=getappdata(handles.figure1,'img1');
    img2 = imnoise(img2,'poisson');
    axes(handles.axes2);
    imshow(img2);
    setappdata(handles.figure1,'img2',img2);
    set(handles.menu_quzaodesc, 'Enable', 'on');
    set(handles.pushbutton_listen, 'Enable', 'on');
case '斑点噪声speckle' % 
	img2=getappdata(handles.figure1,'img1');
    img2 = imnoise(img2,'speckle');
    axes(handles.axes2);
    imshow(img2);
    setappdata(handles.figure1,'img2',img2);
    set(handles.menu_quzaodesc, 'Enable', 'on');
    set(handles.pushbutton_listen, 'Enable', 'on');
end

% --- Executes during object creation, after setting all properties.
function popupmenu_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu (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 myfile_Callback(hObject, eventdata, handles)
% hObject    handle to myfile (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function myfile_open_Callback(hObject, eventdata, handles)
% hObject    handle to myfile_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; ','Image Files(*.bmp,*.jpg,*.png,*.jpeg)';...
    '*.*',      'All Files(*.*)' }...
    , 'Pick an image');%打开文件 选择图像
if isequal(filename,0) || isequal(pathname,0)
    return;%如 果点了“ 取 消”
end
axes(handles.axes1);%重要,在哪个坐标轴显示图像
fpath = [pathname filename];%路径名和文件名
img1 = imread(fpath);%读取图像 
imshow(img1);%显示图像
setappdata(handles.figure1,'img1',img1);


% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (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 popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3
img2=getappdata(handles.figure1,'img2');%加噪图像
img1=getappdata(handles.figure1,'img1');%原始图像
val = get(hObject,'Value');
str = get(hObject, 'String');
switch str{val};
case '中值滤波'
    set(handles.uipanel_lowfilt, 'Visible', 'off');
    set(handles.uipanel_gausslow, 'Visible', 'off');
    set(handles.pushbutton_quzao, 'Visible', 'off');
	img3 = medfilt2(img2);%中值滤波
    setappdata(handles.figure1,'img3',img3);
    axes(handles.axes3);
    imshow(img3);
    PSNR = psnr2(img3, img1);
    str1 = strcat('psnr为: ' , num2str(PSNR) , 'db');
    set(handles.text3, 'string', str1); %显示PSNR值
    set(handles.save, 'Enable', 'on');
   % set(handles.myimage_compress,'Enable', 'on');
    set(handles.pushbutton_compress,'Enable', 'on');
case '维纳滤波' 
    set(handles.uipanel_lowfilt, 'Visible', 'off');
    set(handles.uipanel_gausslow, 'Visible', 'off');
    set(handles.pushbutton_quzao, 'Visible', 'off');
	img3 = wiener2(img2,[5,5]);
    setappdata(handles.figure1,'img3',img3);
    axes(handles.axes3);
    imshow(img3); 
    PSNR = psnr2(img3, img1);
    str1 = strcat('psnr为: ' , num2str(PSNR) , 'db');
    set(handles.text3, 'string', str1);
   % set(handles.myimage_compress,'Enable', 'on');
    set(handles.pushbutton_compress,'Enable', 'on');
    set(handles.save, 'Enable', 'on');

三、运行结果

【图像去噪】基于matlab GUI中值+小波+维纳+滤波器图像去噪【含Matlab源码 616期】
【图像去噪】基于matlab GUI中值+小波+维纳+滤波器图像去噪【含Matlab源码 616期】
【图像去噪】基于matlab GUI中值+小波+维纳+滤波器图像去噪【含Matlab源码 616期】
【图像去噪】基于matlab GUI中值+小波+维纳+滤波器图像去噪【含Matlab源码 616期】
【图像去噪】基于matlab GUI中值+小波+维纳+滤波器图像去噪【含Matlab源码 616期】

四、备注

版本:2014a

完整代码或代写加1564658423

上一篇:plt和opencv显示区别


下一篇:学习笔记-使用Python对含有椒盐噪声的图像进行均值滤波,高斯滤波和中值滤波