function varargout = final(varargin)
% FINAL MATLAB code for final.fig
% FINAL, by itself, creates a new FINAL or raises the existing
% singleton*.
%
% H = FINAL returns the handle to a new FINAL or the handle to
% the existing singleton*.
%
% FINAL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FINAL.M with the given input arguments.
%
% FINAL('Property','Value',...) creates a new FINAL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before final_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to final_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 final
% Last Modified by GUIDE v2.5 01-Jun-2014 09:41:09
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @final_OpeningFcn, ...
'gui_OutputFcn', @final_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 final is made visible.
function final_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 final (see VARARGIN)
% Choose default command line output for final
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes final wait for user response (see UIRESUME)
% uiwait(handles.figure1);
global img_src
backgroundImage=importdata('aa.bmp');
axes(handles.axes3);
image(backgroundImage);
axis off
% --- Outputs from this function are returned to the command line.
function varargout = final_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 during object creation, after setting all properties.
function axes_src_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes_src (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes_src
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global img_src;
[filename,pathname]=uigetfile('*.avi','请选择文件');
axes(handles.axes_src);
fpath=[pathname filename];
obj = VideoReader(fpath);
numFrames = obj.NumberOfFrames;% 帧的总数
for k = 1 : numFrames% 读取数据
frame = read(obj,k);
imwrite(frame,strcat('f:/',num2str(k),'.jpg'),'jpg');% 保存帧
%HSV
rgb= imread(strcat('f:/',num2str(k),'.jpg'),'jpg');
gray=rgb2gray(rgb);
[width height]=size(gray);%%% height表示图像高度350,width为图像宽度688
r=rgb(:,:,1); %R,G,B分量
g=rgb(:,:,2);
b=rgb(:,:,3);
hsv=rgb2hsv(rgb);
h=hsv(:,:,1); %HSV空间H,S,V分量
s=hsv(:,:,2);
v=hsv(:,:,3);
[p,q] = size(s);
for i=1:width
for j=1:height
if ((rgb(i,j,1)>rgb(i,j,2)) && (rgb(i,j,2)>=rgb(i,j,3)) && (rgb(i,j,1)>101)&&(s(i,j)>0.6))
ss(i,j)=1;
else
ss(i,j)=0;
end
end
end
%imshow(ss);
%统计白点
bw=im2bw(ss,0.5);
[a,b,c]=size(rgb); %图片size
white=0; %黑点个数
for i=1:a
for j=1:b
if (bw(i,j)==0)
white=white+1;
end
end
end
axes(handles.axes_src);
imshow(frame);%显示帧
%if(white>0)
axes(handles.axes_des);
imshow(ss);
%end
%
end
% --------------------------------------------------------------------
% --- Executes during object creation, after setting all properties.
function axes_des_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes_des (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes_des
% --- Executes during object creation, after setting all properties.
function axes_des_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes_des (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes_des