⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zaosheng2.m

📁 均值滤波,加权滤波,中值滤波的MATLAB实例,用于图象及信号的处理
💻 M
字号:
function varargout = zaosheng2(varargin)
% ZAOSHENG2 M-file for zaosheng2.fig
%      ZAOSHENG2, by itself, creates a new ZAOSHENG2 or raises the existing
%      singleton*.
%
%      H = ZAOSHENG2 returns the handle to a new ZAOSHENG2 or the handle to
%      the existing singleton*.
%
%      ZAOSHENG2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ZAOSHENG2.M with the given input arguments.
%
%      ZAOSHENG2('Property','Value',...) creates a new ZAOSHENG2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before zaosheng2_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to zaosheng2_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help zaosheng2

% Last Modified by GUIDE v2.5 04-Dec-2007 16:03:48

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = zaosheng2_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 open1.
function open1_Callback(hObject, eventdata, handles)
% hObject    handle to open1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[file,path]=uigetfile('*.jpg;*.tif');
if isequal(file,0)
   disp('User selected Cancel')
else
  filename=fullfile(path,file);
end
handles.my_file1=filename;
guidata(hObject,handles);


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

% Hints: get(hObject,'String') returns contents of mobanshu1 as text
%        str2double(get(hObject,'String')) returns contents of mobanshu1 as a double


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

% Hint: edit 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 plot1.
function plot1_Callback(hObject, eventdata, handles)
% hObject    handle to plot1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%%显示源图像
filename=handles.my_file1;
picture=imread(filename);
[r,c,d]=size(picture);
axes(handles.yuantu1)
set(handles.yuantu1, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[0 r],'yLim',[0 c]);
imshow(picture);
hold on
%显示滤波后的图像
m=str2double(get(handles.mobanshu1,'String'));
G=my_gaosi(filename,m);
axes(handles.bianhuan1)
set(handles.bianhuan1, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[0 r],'yLim',[0 c]);
imshow(G);
hold on



% --- Executes on button press in open2.
function open2_Callback(hObject, eventdata, handles)
% hObject    handle to open2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[file,path]=uigetfile('*.jpg;*.tif');
if isequal(file,0)
   disp('User selected Cancel')
else
  filename=fullfile(path,file);
end
handles.my_file2=filename;
guidata(hObject,handles);


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

% Hints: get(hObject,'String') returns contents of mobanshu2 as text
%        str2double(get(hObject,'String')) returns contents of mobanshu2 as a double


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

% Hint: edit 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 plot2.
function plot2_Callback(hObject, eventdata, handles)
% hObject    handle to plot2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
filename=handles.my_file2;
picture=imread(filename);
[r,c,d]=size(picture);
axes(handles.yuantu2)
set(handles.yuantu2, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[0 r],'yLim',[0 c]);
imshow(picture);
hold on
%显示滤波后的图像
m=str2double(get(handles.mobanshu2,'String'));
G=my_jiaquan(filename,m);
axes(handles.bianhuan2)
set(handles.bianhuan2, 'Visible', 'off', 'Units', 'pixels' ,'XLim',[0 r],'yLim',[0 c]);
imshow(G);
hold on


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -