function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 19-Oct-10013 13:16:34
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
%**************************************************************************
%
%设置全局变量和初始化
%
%**************************************************************************
global x0 y0 x y
x0=0;
y0=0;
x=0;
y=0;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.Recognition);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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)
%**************************************************************************
%
%获取输入图像信息
%
%**************************************************************************
h=getframe(handles.axes3);%获取坐标axes3的框架
[x,map]=frame2im(h);%转换为矩阵
a(:,:)=x(:,:,1);%转换为303*303的矩阵
clc%清屏
%**************************************************************************
%
%特征值提取
%
%**************************************************************************
CountMatrix(1,100)=0;%先设置一个一行一百列的矩阵,用来存放新的10*10的矩阵
probability = 0;%初始化概率为零
b=1;%初始化CountMatrix的列数为1
%把300*300的矩阵转化成10*10的矩阵
for n = 1:10
for m = 1:10
%上面是把矩阵分块分成10*10的矩阵
Count=0;
for i = 30*n-29:30*n
for j = 30*m-29:30*m
if a(i,j)==0
Count = Count + 1;%计算各个分块矩阵中零的数量
end
end
end
probability = Count/90;
if probability >= 0.99%零的数量在各个分块矩阵中超过99%就算是一。
CountMatrix(1,b) = 1;
end
b = b + 1;
probability = 0;
end
end
global B%设置B为全局变量
B(10,10)=0;
for i = 1:10
for j = 1:10
B(i,j) = CountMatrix(1,10*(i-1)+j);%把1*100的矩阵转化成10*10的矩阵
end
end
B
%**************************************************************************
%
%在GUI界面输出特征值信息
%
%**************************************************************************
axes(handles.axes9);
set(gca,'xLim',[0.1,1.1],'yLim',[0,1.1]);%设定输出坐标的范围
for i=1:10
for j=1:10
if CountMatrix(1,10*(i-1)+j)>0.1
text(double(j*0.1),double((11-i)*0.1),'■','FontSize',25,'Color',[0,0,0]);%在屏幕上输出特征信息
end
end
end
% 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)
% --- Executes on button press in Clear.
function Clear_Callback(hObject, eventdata, handles)
%**************************************************************************
%
%清除屏幕上的图案
%
%**************************************************************************
cla(handles.axes3);
cla(handles.axes9);
% hObject handle to Clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes1 (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 axes1
% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function Recognition_WindowButtonDownFcn(hObject, eventdata, handles)
%**************************************************************************
%
%鼠标按下的时候记录鼠标的坐标
%
%**************************************************************************
global x0 y0 flag
flag=1;
curPt=get(gca,'currentpoint');
x0=curPt(1,1);
y0=curPt(1,2);
% hObject handle to Recognition (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on mouse motion over figure - except title and menu.
function Recognition_WindowButtonMotionFcn(hObject, eventdata, handles)
%**************************************************************************
%
%鼠标移动的时候记录新的坐标并在中间画线
%
%**************************************************************************
global x0 y0 flag
if flag
legend(handles.axes3,'off');
curPt=get(gca,'currentpoint');
x=curPt(1,1);
y=curPt(1,2);
line([x0,x],[y0,y],'LineWidth',10,'color',[0,0,0])
x0=x;
y0=y;
end
% hObject handle to Recognition (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
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 dou