readsigimages.m
来自「脱机手写体识别Matlab源程序 包括特征提取、bayes分类器、K近邻分类及」· M 代码 · 共 40 行
M
40 行
% ReadSigImages
% 读取文件,并提取每幅图像的特征
% 返回
% featureVector 特征矩阵,每一列表示一个样本
% classLabVector 样本类标
% by kofsky 6.3
function [featureVector,classLabVector]=ReadSigImages(filepath)
% 读取包含签字文件的文件夹名
AllDirs=dir(filepath);
if length(AllDirs)>0
if AllDirs(1).name == '.',
dirs = AllDirs(3:end); % 存放签字文件的目录
end
end
featureVector=[]; % 特征矩阵
classLabVector=[]; % 样本类标
for i=1:length(dirs)
SubDirFiles = dir(strcat(filepath,dirs(i).name));
curClassFeaVec=[];
if length(SubDirFiles)>0
if SubDirFiles(1).name == '.',
files = SubDirFiles(3:end);
for j=1:length(files)
curFilename=strcat(filepath,dirs(i).name,'\',files(j).name);
Image=imread(curFilename); % 读入签字文件
[curFeaVec]=ScriptFeaExtract(Image); % 提取特征
curClassFeaVec=[curClassFeaVec curFeaVec]; % 添加特征向量
disp(curFilename)
end
featureVector=[featureVector curClassFeaVec]; % 特征矩阵
classLabVector=[classLabVector i*ones(1,length(files))]; % 样本类标
end
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?