function varargout = carcheck(varargin)
% CARCHECK M-file for carcheck.fig
% CARCHECK, by itself, creates a new CARCHECK or raises the existing
% singleton*.
%
% H = CARCHECK returns the handle to a new CARCHECK or the handle to
% the existing singleton*.
%
% CARCHECK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CARCHECK.M with the given input arguments.
%
% CARCHECK('Property','Value',...) creates a new CARCHECK or raises the
% existing singleton*. Starting from the left, property value pairs are
%applied to the GUI before carcheck_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to carcheck_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 carcheck
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @carcheck_OpeningFcn, ...
'gui_OutputFcn', @carcheck_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 carcheck is made visible.
function carcheck_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 carcheck (see VARARGIN)
% Choose default command line output for carcheck
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes carcheck wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = carcheck_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)
%选择打开指定图像
%选择图片路径
[fname,pname,index] = uigetfile({'*.jpg';'*.bmp'},'选择图片');
str = [pname fname];
streetcar = imread(str);
axes(handles.axes1); %获取句柄
imshow(streetcar);
title('原图');
handles.streetcar=streetcar; %保存起来
set(handles.text4,'string','选择图像完成。')
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)
streetcar=handles.streetcar;
c=streetcar;
b=imread('street.jpg');
c=imsubtract(c,b);
axes(handles.axes2)
imshow(c)
title('作差结果')
set(handles.text4,'string','作差完成')
handles.c=c;
handles.b=b;
streetcar=handles.streetcar;
guidata(hObject, handles);
% --- 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 = 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: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
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
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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 pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
c=handles.c;
b=handles.b;
streetcar=handles.streetcar;
%将待识别图像与背景图像进行比较,识别出车子,并只留下车子
for i=1:600
for j=1:800
if (abs(double(b(i,j,1))-double(streetcar(i,j,1)))>2)
c(i,j,1)=0;
c(i,j,2)=0;
c(i,j,3)=0;
elseif (abs(double(b(i,j,2))-double(streetcar(i,j,2)))>2)
c(i,j,1)=0;
c(i,j,2)=0;
c(i,j,3)=0;
elseif (abs(double(b(i,j,3))-double(streetcar(i,j,3)))>2)
c(i,j,1)=0;
c(i,j,2)=0;
c(i,j,3)=0;
else
c(i,j,1)=255;
c(i,j,2)=255;
c(i,j,3)=255;
end
end
end
%图像处理,包括灰度化,二值化和腐蚀,去除噪声
c=rgb2gray(c);
axes(handles.axes3)
imshow(c)
title('灰度图')
handles.c=c;
guidata(hObject, handles);
set(handles.text4,'string','灰度处理完成')
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% ha
weixin_51926946
- 粉丝: 0
- 资源: 1
最新资源
- 图像识别实战项目-基于深度学习与多种应用领域的图像处理与分析
- golin 扫描工具使用, 检查系统漏洞、web程序漏洞
- 多种编程语言下的算法实现资源及其应用场景
- BGM坏了吗111111
- 高等工程数学试题详解:矩阵分析与最优化方法
- 这是一个以20位中国著名书法家的风格编写的汉字作品的数据集 每个子集中有1000-7000张jpg图像(平均5251张图像)
- 【Academic tailor】学术小裁缝必备知识点:全局注意力机制(GAM)pytorch
- 数据科学领域的主流数据集类型及其应用分析
- 【Academic tailor】学术小裁缝必备知识点:全局注意力机制(GAM)TensorFlow
- Apple MacBook Pro和macOS Monterey用户的全方位使用指南
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
前往页