【图像去噪】基于matlab GUI均值+中值+空间+高斯滤波图像去噪【含Matlab源码 763期】

一、简介

基于matlab GUI均值+中值+空间+高斯滤波图像去噪

二、源代码

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

% Last Modified by GUIDE v2.5 12-Apr-2021 09:31:49

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @noise_filter_OpeningFcn, ...
                   'gui_OutputFcn',  @noise_filter_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 noise_filter is made visible.
function noise_filter_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 noise_filter (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = noise_filter_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)
%选择图片,可以是以下格式(*这个符号是通配符,表示可以是任意长度的任意字符)
    [filename,pathname]=uigetfile({
     '*.*';'*.bmp';'*.jpg';'*.tif';'*.jpeg'},'选择图像');
    %将im定义成全局变量,这样在代码的任何位置都可以使用im了。
    global im;
    %如果没有输入路径,则弹出错误对话框 
    if isequal(filename,0)||isequal(pathname,0)
      errordlg('您还没有选取图片!!','程序员哥哥告诉你');
      return;
    else
        %合成路径+文件名
        image=[pathname,filename];
        %读取图像
        im=imread(image);
        %打开坐标,方便操作
        set(handles.axes1,'HandleVisibility','ON');
        %使用图像,操作在坐标axes1里
        axes(handles.axes1);
        %在坐标图axes1里显示原图像 
        imshow(im);
        title('原始图像');
    end


% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (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 listbox1 contents as cell array
%        contents{
     get(hObject,'Value')} returns selected item from listbox1


% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 button press in radiobutton1.

function radiobutton1_Callback(hObject, eventdata, handles)
global gs;
global jy;
global zs;
global ps;
jy=0;
gs=1;
zs=0;
ps=0;


% hObject    handle to radiobutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1


% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
global gs;
global jy;
global zs;
global ps;
jy=1;
gs=0;
zs=0;
ps=0;


% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2


% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
global gs;
global jy;
global zs;
global ps;
jy=0;
gs=0;
zs=1;
ps=0;


% hObject    handle to radiobutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton3


% --- Executes on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to listbox2 (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 listbox2 contents as cell array
%        contents{
     get(hObject,'Value')} returns selected item from listbox2


% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global zzl;
global jzl;
global kjl;
global gsl;
jzl=1;
zzl=0;
kjl=0;
gsl=0;

% Hint: get(hObject,'Value') returns toggle state of radiobutton4


% --- Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global zzl;
global jzl;
global kjl;
global gsl;
jzl=0;
zzl=1;
kjl=0;
gsl=0;
% Hint: get(hObject,'Value') returns toggle state of radiobutton5

三、运行结果

【图像去噪】基于matlab GUI均值+中值+空间+高斯滤波图像去噪【含Matlab源码 763期】_第1张图片

四、备注

完整代码或者代写添加QQ 1564658423

你可能感兴趣的:(matlab,图像处理)