function varargout = main(varargin)
% MAIN MATLAB code for main.fig
% MAIN, by itself, creates a new MAIN or raises the existing
% singleton*.
%
% H = MAIN returns the handle to a new MAIN or the handle to
% the existing singleton*.
%
% MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN.M with the given input arguments.
%
% MAIN('Property','Value',...) creates a new MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_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 main
% Last Modified by GUIDE v2.5 31-May-2016 17:38:07
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_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 main is made visible.
function main_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 main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
clc; warning off all;
axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes5); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes6); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes7); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes8); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes9); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes10); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes11); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes12); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes13); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes14); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes15); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
set(handles.edit1, 'string', []);
handles.Img=[];
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = main_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;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 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)
axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes5); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes6); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes7); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes8); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes9); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes10); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes11); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes12); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes13); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes14); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes15); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
set(handles.edit1, 'string', []);
set(handles.edit2, 'string', []);
[filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif', 'All Image Files';...
'*.*', '所有文件' }, '选择图像文件', fullfile(pwd, 'images/川F1A666.jpg'));
if filename == 0
return;
end
% 文件名
file = fullfile(pathname, filename);
% 图像矩阵
Img = imread(file);
%激活第一个轴对象
axes(handles.axes1);
imshow(Img, []);
%激活第二个轴对象
axes(handles.axes2);
imshow(Img, []);
%保存为全局变量
handles.Img = Img;
guidata(hObject, handles);
% --- 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)
Img=handles.Img;
%对图像I进行灰度处理
I_gray=rgb2gray(Img);
axes(handles.axes3);
imshow(I_gray);
title('灰度图像');
%利用Sobel算子进行边缘检测
I_edge=edge(I_gray,'sobel');
axes(handles.axes4);
imshow(I_edge)
title('边缘检测后图像');
se=[1;1;1];
%对边缘图像进行腐蚀
I_erode=imerode(I_edge,se);
axes(handles.axes5);
imshow(I_erode);
title('腐蚀后边缘图像');
se=strel('rectangle',[25,25]);
%填充图像
I_close=imclose(I_erode,se);
axes(handles.axes6);
imshow(I_close)
title('填充后图像');
%去除聚团灰度值小于1500的部分
I_final=bwareaopen(I_close,1500);
axes(handles.axes7);
imshow(I_final);
title('形态滤波后图像');
I_new=zeros(size(I_final,1),size(I_final,2));
location_of_1=[];
%寻找二值图像中
不脱发的程序猿
- 粉丝: 26w+
- 资源: 5887
最新资源
- 基于智慧教室管理系统全部资料+高分项目+详细文档.zip
- 基于智慧教室监考系统,作弊检测和考生点名功能全部资料+高分项目+详细文档.zip
- 基于智慧教学辅助系统全部资料+高分项目+详细文档.zip
- 基于智慧酒店后台管理系统全部资料+高分项目+详细文档.zip
- 基于智慧景区管理系统,目前已完成票务系统、设备管理、停车场管理、用户权限控制、设备权限控制、小程序售票等功能的开发!全部资料+高分项目+详细文档.zip
- 基于智慧教育后台管理子系统全部资料+高分项目+详细文档.zip
- 基于智慧楼宇碳检测系统全部资料+高分项目+详细文档.zip
- 基于智慧课堂管理系统前端全部资料+高分项目+详细文档.zip
- 基于智慧课堂管理系统全部资料+高分项目+详细文档.zip
- 基于智慧农业集成管理系统全部资料+高分项目+详细文档.zip
- 基于智慧旅游售票管理系统全部资料+高分项目+详细文档.zip
- 基于智慧农业监控管理系统全部资料+高分项目+详细文档.zip
- 基于智慧农业系统全部资料+高分项目+详细文档.zip
- 基于智慧社区管理系统项目全部资料+高分项目+详细文档.zip
- 基于智慧书店管理系统全部资料+高分项目+详细文档.zip
- 基于智慧水务后台管理系统全部资料+高分项目+详细文档.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈