function varargout = cargui(varargin)
% CARGUI MATLAB code for cargui.fig
% CARGUI, by itself, creates a new CARGUI or raises the existing
% singleton*.
%
% H = CARGUI returns the handle to a new CARGUI or the handle to
% the existing singleton*.
%
% CARGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CARGUI.M with the given input arguments.
%
% CARGUI('Property','Value',...) creates a new CARGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before cargui_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to cargui_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 cargui
% Last Modified by GUIDE v2.5 03-Jun-2013 12:32:43
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @cargui_OpeningFcn, ...
'gui_OutputFcn', @cargui_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 cargui is made visible.
function cargui_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 cargui (see VARARGIN)
% Choose default command line output for cargui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes cargui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = cargui_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 btread.
function btread_Callback(hObject, eventdata, handles)
% hObject handle to btread (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global image
%—————————————读入图像——————————————
[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;
fpath=[pathname filename];
image=imread(fpath);
axes(handles.axin);
axis on;
imshow(image);
axis equal;
% --- Executes on button press in btnbina.
function btnbina_Callback(hObject, eventdata, handles)
% hObject handle to btnbina (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global image
global imgb;
if isgray(image)==0
image=rgb2gray(image);
end
u1=mean(mean(image));
[m,n]=size(image);
mse1=sqrt(sum(sum((image-u1).^2))/(m*n));
a=u1/mse1;
thr1=u1-20*mse1/a;
npt=image(image<thr1);
num=length(npt);
u2=mean(npt);
mse2=sqrt(sum((npt-u2).^2)/num);
b=u2/mse2;
thr2=u2-mse2/b;
imgb=image>thr2;
axes(handles.axout);
axis on;
imshow(imgb);
axis equal;
% --- Executes on button press in btncar.
function btncar_Callback(hObject, eventdata, handles)
% hObject handle to btncar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global lenrb
global image
global imgreg;
nwlenr=lenrb(lenrb~=0)
numnw=length(nwlenr);
axes(handles.axout);
axis on;
imshow(image);
axis equal;
hold on
for k=1:numnw
gregw=nwlenr(k);
[mgw,ngw]=find(imgreg==gregw);
ngwmax=max(ngw)+5;
ngwmin=min(ngw)-5;
hw=mgw(1)-1.2*(ngwmax-ngwmin);
if hw<0
hw=2;
end
plot([ngwmin ngwmin],[hw mgw(1)],'Linewidth',2,'color','red');
plot([ngwmax ngwmax],[hw mgw(1)],'Linewidth',2,'color','red');
plot([ngwmin ngwmax],[hw hw],'Linewidth',2,'color','red');
plot([ngwmin ngwmax],[mgw(1) mgw(1)],'Linewidth',2,'color','red');
end
% --- Executes on button press in btnshad.
function btnshad_Callback(hObject, eventdata, handles)
% hObject handle to btnshad (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global image;
global imgb;
global lenrb;
global imgreg;
[m,n]=size(image);
imgreg=zeros(m,n);
reg=0;
%%%区域编号
for i=1:m
if i>1 && image(i-1,n)==1
reg=reg+1;
end
for j=1:n
if imgb(i,j)==0
imgreg(i,j)=reg;
if j<n && imgb(i,j+1)==1
reg=reg+1;
end
end
end
end
numr=max(max(imgreg));
numl=0;
%%%%寻找可疑区域
for k=1:numr%这里的k对应区域编号
len=sum(sum(imgreg==k));
[ml,nl]=find(imgreg==k);
lenpre=0.92*ml(1)+0.78;
if len>0.7*lenpre && len<1.5*lenpre
if len>50 &&len<150
numl=numl+1;
lenr(numl)=k;%记录满足条件的区号
end
end
end
numlen=length(lenr);
for k=2:numlen
greg2=lenr(k);
[mg2,ng2]=find(imgreg==greg2);
ng2max=max(ng2);
ng2min=min(ng2);
greg1=lenr(k-1);
[mg1,ng1]=find(imgreg==greg1);
ng1max=max(ng1);
ng1min=min(ng1);
if mg2(1)-mg1(1)<10
lenr(k-1)=0;
if ng2max<ng1max
imgreg(mg2(1),ng2max+1:ng1max)=greg2;
end
if ng2min>ng1min
imgreg(mg2(1),ng1min:ng2min-1)=greg2;
end
end
end
axes(handles.axout);
axis on;
imshow(image);
axis equal;
hold on
for k=1:numlen
greg=lenr(k);
if greg~=0
[mg,ng]=find(imgreg==greg);
plot(ng,mg,'Linewidth',2,'color','red');
end
end
lenrb=lenr;
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【达摩老生出品,必属精品,亲测校正,质量保证】 资源名:基于阴影分割的车辆检测识别_阴影分割_车辆检测_matlab 资源类型:matlab项目全套源码 源码说明: 全部项目源码都是经过测试校正后百分百成功运行的,如果您下载后不能运行可联系我进行指导或者更换。 适合人群:新手及有一定经验的开发人员
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![m](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/DOCX.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/MP4.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/MP4.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 9 条
- 1
![avatar](https://profile-avatar.csdnimg.cn/2588731bac124b388c4a87fce0b1493c_m0_53407570.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
阿里matlab建模师
- 粉丝: 3377
- 资源: 2786
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
- 1
- 2
前往页