📄 gskmadechar.m
字号:
function varargout = gskmadechar(varargin)
% GSKMADECHAR M-file for gskmadechar.fig
% GSKMADECHAR, by itself, creates a new GSKMADECHAR or raises the existing
% singleton*.
%
% H = GSKMADECHAR returns the handle to a new GSKMADECHAR or the handle to
% the existing singleton*.
%
% GSKMADECHAR('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GSKMADECHAR.M with the given input arguments.
%
% GSKMADECHAR('Property','Value',...) creates a new GSKMADECHAR or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gskmadechar_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gskmadechar_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 gskmadechar
% Last Modified by GUIDE v2.5 23-Mar-2008 23:58:49
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gskmadechar_OpeningFcn, ...
'gui_OutputFcn', @gskmadechar_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 gskmadechar is made visible.
function gskmadechar_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 gskmadechar (see VARARGIN)
% Choose default command line output for gskmadechar
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gskmadechar wait for user response (see UIRESUME)
% uiwait(handles.figure1);
clc
clear global
global inmv000 wtmv000 incmv000 iolmv000
inmv000 = zeros(100,1);
inmv000 = (-1) + inmv000;
incmv000 = zeros(1,100);
incmv000 = (-1) + incmv000;
iolmv000 = 45;
wtmv000 = zeros(100,100);
wtmv000 = wtmv000 + (inmv000 * inmv000');
%for intv011 = 1:100
% wtmv000(intv011,intv011) = 0;
%end
% --- Outputs from this function are returned to the command line.
function varargout = gskmadechar_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)
global wtmv000 inmv000 incmv000 iolmv000
inmv001 = zeros(100,1);
inmv001 = (-1) + inmv001;
chrv000 = cd;
chrv001 = get(handles.edit1,'string');
chrv002 = get(handles.edit3,'string');
chrvv002 = str2double(chrv002);
dos('%SystemRoot%\system32\mspaint.exe gskchar.bmp');
un8v000 = imread(fullfile(chrv000,'gskchar.bmp'));
%calculation of x1, y1, x2, y2
[intv000,intv001,intv002] = size(un8v000);
intv005 = 0;
intv006 = 0;
intv007 = 0;
intv008 = 0;
intv009 = intv000;
intv010 = intv001;
for intv003 = 1:intv000
intv007 = 0;
for intv004 = 1:intv001
if (un8v000(intv003,intv004,1) ~= 255) || (un8v000(intv003,intv004,2) ~= 255) || (un8v000(intv003,intv004,3) ~= 255)
intv007 = intv007 + 1;
if intv007 == 1
intv009 = min(intv003,intv009);
intv010 = min(intv004,intv010);
end
intv005 = max(intv005,intv003);
intv006 = max(intv006,intv004);
end
end
end
if ((intv005 == intv009) || (intv006 == intv010)) || (intv005 == 0) || (intv006 == 0) || (intv009 == 0) || (intv010 == 0)
msgbox([{'Image cannot have less than 2 lines (line must be longer than 2 pixels)',char(13),'Retrieval is not sucessful'}],'ChrRecg - GSK');
else
if (intv005 - intv009) > (intv006 - intv010)
intv003 = 9 / (intv005 - intv009);
else
intv003 = 9 / (intv006 - intv010);
end
axes(handles.axes1);
% figure
cla
hold on
for intv011 = 1 : intv000
for intv012 = 1 : intv001
if (un8v000(intv011,intv012,1) ~= 255) || (un8v000(intv011,intv012,2) ~= 255) || (un8v000(intv011,intv012,3) ~= 255)
intv013 = round(intv003 * (intv011 -intv009)) + 1;
intv014 = round(intv003 * (intv012 -intv010)) + 1;
inmv001((intv013-1) * 10 + intv014,1) = 1;
plot(intv014,-intv013);
end
end
end
xlim([0 11]);
ylim([-11 0]);
hold off
logv000 = 0;
intv004 = 0;
intv005 = 0;
[intv000,intv001] = size(incmv000);
opmv000 = inmv001;
while logv000 == 0
intv004 = intv004 + 1;
intv016(1:intv000,1) = zeros(intv000,1);
for intv002 = 1 : intv000
intv015(1:100,1) = incmv000(intv002,1:100) - opmv000(1:100,1)';
intv016(intv002,1) = norm(intv015(1:100,1));
end
intv017 = min(intv016);
intv018 = 0;
for intv002 = 1 : intv000
if intv016(intv002,1) == intv017;
intv018 = intv018 + 1;
intv003 = intv002;
end
end
if (intv018 == 1)
logv000 = 1;
end
inmmv001 = opmv000;
if logv000 ~= 1
if intv004 > 100
intv004 = intv004 - 100;
end
intv005 = intv005 + 1;
if get(handles.checkbox2,'value') == 1
inmv001(intv004,1) = opmv000(intv004,1);
else
inmv001 = opmv000;
end
end
if intv005 == chrvv002 * 10000
msgbox([{'Processing taking too long',char(13),'Retrieval is not sucessful'}],'ChrRecg - GSK');
logv000 = 1;
intv003 = 1;
end
opmv000 = wtmv000' * inmv001;
for intv002 = 1 : 100
if opmv000(intv002) < 0
opmv000(intv002) = -1;
else
opmv000(intv002) = 1;
end
end
end
set(handles.edit4,'string',num2str(intv005));
chrv001 = strcat(chrv001,char(iolmv000(intv003)));
set(handles.edit1,'string',chrv001);
end
intv000 = get(handles.checkbox1,'value');
intvs000 = num2str(intv000);
if intvs000 == '1'
gskmadechar('pushbutton1_Callback',hObject, eventdata, handles)
end
% --- 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)
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)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit1,'string','');
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global inmv000 wtmv000 incmv000 iolmv000
[chrv002,chrv003]=uiputfile('*.mat','Select a File to store Data');
if ~(num2str(chrv002) == '0');
save(fullfile(chrv003,chrv002));
msgbox('Saving is sucessful','ChrRecg - GSK');
else
msgbox([{'You Have Specify File To Save Data',char(13),'Saving is not sucessful'}],'ChrRecg - GSK');
end
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[chrv005,chrv006]=uigetfile('*.mat','Select a File to Load Data');
if (num2str(chrv005) == '0');
msgbox([{'You Have Specify File To Save Data',char(13),'Loading is not sucessful'}],'ChrRecg - GSK');
else
chrv007 = questdlg([{'This will delete present learned data!!!'};{'Are You Sure ???'}],'Question ?','Yes','No.','No.','Yes');
if chrv007 == 'Yes'
chrv008 = handles;
load(fullfile(chrv006,chrv005));
else
msgbox([{'Cancelled by user',char(13),'Loading is not sucessful'}],'ChrRecg - GSK');
end
end
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global wtmv000 inmv000 incmv000 iolmv000
inmv000 = zeros(100,1);
inmv000 = (-1) + inmv000;
chrv000 = cd;
chrv001 = get(handles.edit2,'string');
dos('%SystemRoot%\system32\mspaint.exe gskchar.bmp');
un8v000 = imread(fullfile(chrv000,'gskchar.bmp'));
%calculation of x1, y1, x2, y2
[intv000,intv001,intv002] = size(un8v000);
intv005 = 0;
intv006 = 0;
intv007 = 0;
intv008 = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -