• zjuzjz
    了解作者
  • matlab
    开发工具
  • 2KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2019-12-18 09:37
    上传日期
用形态变换生成字母A-M的训练集(每个字母800张)和测试集(每个字母2000张)
Letters.rar
  • Test_Letters.m
    13.4KB
  • Train_Letters.m
    14.2KB
内容介绍
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 2019年5月18日 作者:竺家柱 % 需要处理的字母有A-M共13个 % 在Letters文件夹各个子文件夹中有每个字母的原始素材 % 每个字母三张素材,格式为.png % 利用这三张素材进行缩放、旋转、位移,得到训练集(jpg格式) % 修改11行的内容就可以在A-M文件夹中生成数据 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear;clc; mod = 'A';%把这一行的字母改了 Path_meterial1 = strcat('Letters/',mod,'/',mod,'1.jpg'); Path_meterial2 = strcat('Letters/',mod,'/',mod,'2.jpg'); Path_meterial3 = strcat('Letters/',mod,'/',mod,'3.jpg'); % A1_gray = rgb2gray(imread(Path_meterial1)); % A2_gray = rgb2gray(imread(Path_meterial2)); % A3_gray = rgb2gray(imread(Path_meterial3)); A1_gray = imread(Path_meterial1); A2_gray = imread(Path_meterial2); A3_gray = imread(Path_meterial3); A1_double = im2double(A1_gray); A2_double = im2double(A2_gray); A3_double = im2double(A3_gray); Path_File = strcat('A-M/Train/Together','/',mod,'_'); i = 1; %% 旋转处理 for theta = -50:3:55 img = imrotate(A1_double,theta); img = imresize(img,[28 28]); path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); imwrite(img,path); i = i+1; end for theta = -50:3:55 img = imrotate(A2_double,theta); img = imresize(img,[28 28]); path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); imwrite(img,path); i = i+1; end for theta = -50:3:55 img = imrotate(A3_double,theta); img = imresize(img,[28 28]); path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); imwrite(img,path); i = i+1; end % %% 缩放处理 % for thick = 4:4:32 % [H,W] = size(A1_double); % img = zeros(H+thick*2,W+thick*2); % img(thick+1:thick+H,thick+1:thick+W) = A1_double; % img = imresize(img,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % % for thick = 4:4:32 % [H,W] = size(A2_double); % img = zeros(H+thick*2,W+thick*2); % img(thick+1:thick+H,thick+1:thick+W) = A2_double; % img = imresize(img,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % for thick = 4:4:32 % [H,W] = size(A3_double); % img = zeros(H+thick*2,W+thick*2); % img(thick+1:thick+H,thick+1:thick+W) = A3_double; % img = imresize(img,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % %% 位置调节 % for position = -10:2:10 % %向下移动 % img_d = circshift(A1_double,10); % img = imresize(img_d,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向左下移动 % img_dl = circshift(img_d,[1,-10]); % img = imresize(img_dl,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向右下移动 % img_dr = circshift(img_d,[1,10]); % img = imresize(img_dr,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向上移动 % img_u = circshift(A1_double,-10); % img = imresize(img_u,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向左上移动 % img_ul = circshift(img_u,[1,-10]); % img = imresize(img_ul,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向右上移动 % img_ur = circshift(img_u,[1,10]); % img = imresize(img_ur,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % % for position = -10:2:10 % %向下移动 % img_d = circshift(A2_double,10); % img = imresize(img_d,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向左下移动 % img_dl = circshift(img_d,[1,-10]); % img = imresize(img_dl,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向右下移动 % img_dr = circshift(img_d,[1,10]); % img = imresize(img_dr,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向上移动 % img_u = circshift(A2_double,-10); % img = imresize(img_u,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向左上移动 % img_ul = circshift(img_u,[1,-10]); % img = imresize(img_ul,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向右上移动 % img_ur = circshift(img_u,[1,10]); % img = imresize(img_ur,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % % for position = -10:2:10 % %向下移动 % img_d = circshift(A3_double,10); % img = imresize(img_d,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向左下移动 % img_dl = circshift(img_d,[1,-10]); % img = imresize(img_dl,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向右下移动 % img_dr = circshift(img_d,[1,10]); % img = imresize(img_dr,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向上移动 % img_u = circshift(A3_double,-10); % img = imresize(img_u,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向左上移动 % img_ul = circshift(img_u,[1,-10]); % img = imresize(img_ul,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % %向右上移动 % img_ur = circshift(img_u,[1,10]); % img = imresize(img_ur,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % %% 位置与缩放的结合 % for position = -10:2:10 % %向下移动 % img_d = circshift(A2_double,10); % % for thick = 4:4:24 % [H,W] = size(img_d); % img = zeros(H+thick*2,W+thick*2); % img(thick+1:thick+H,thick+1:thick+W) = img_d; % img = imresize(img,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % % %向左下移动 % img_dl = circshift(img_d,[1,-10]); % for thick = 4:4:24 % [H,W] = size(img_dl); % img = zeros(H+thick*2,W+thick*2); % img(thick+1:thick+H,thick+1:thick+W) = img_dl; % img = imresize(img,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % % %向右下移动 % img_dr = circshift(img_d,[1,10]); % for thick = 4:4:24 % [H,W] = size(img_dr); % img = zeros(H+thick*2,W+thick*2); % img(thick+1:thick+H,thick+1:thick+W) = img_dr; % img = imresize(img,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % %向上移动 % img_u = circshift(A1_double,-10); % for thick = 4:4:24 % [H,W] = size(img_u); % img = zeros(H+thick*2,W+thick*2); % img(thick+1:thick+H,thick+1:thick+W) = img_u; % img = imresize(img,[28,28]); % path = strcat(Path_File,num2str(i,'%05d'),'.jpg'); % imwrite(img,path); % i = i+1; % end % %向左上移动 % img_ul = circshift(img_u,[1,-10]); % for thick = 4:4:24 % [H,W] = size(img_ul); % img = zeros(H+thick*2,W+th
评论
    相关推荐
    • SAX-Adaboost.zip
      SAX是一种典型的符号化特征表示方法.该方法在时间序列特征表示中不仅可以有效地降维、降噪,而且具有简单、直观等特点.
    • UNet.zip
      U-Net通俗来讲也是全卷积神经网络的一种变形,主要其结构经论文作者画出来形似字母U(见图 1),因而得名U-Net。整个神经网络主要有两部分组成:搜索路径(contracting path)和扩展路径(expanding path)。搜索...
    • 基于图像不变距的简易手写单个英文字母识别-基于图像不变距的简易单个英文字母识别.rar
      本帖最后由 lgs2007m 于 2016-7-10 14:54 编辑 这个是很久前的课设来的,识别部分的程序是参照国外的Image and Video Processing Project One by Stanislav Rost(居然是98年的……哎,自己好low) ...
    • 2010年考研英语单词象形记忆法
      name n【门-连接】,a【元音字母a、e、i、o、u、y”和“元音字母组合”很多情况下都是表达一个单词的声音,就像汉字形声字的声旁,可以没有含义,可以不解释】,m【移动-跟随】,e【辅音字母+e结尾,表明前面的声...
    • Windows 2000系统编程
      关于Windows2000的系统编程,与大家一起学习
    • Windows2000系统编程教程
      Windows2000系统编程教程,有助于编程爱好者学习。
    • Windows 2000系统编程.pdf
      本书用专业的语言详细地讲解了Windows 2000系统编程的基本概念、技术及最新的相关内容。通过实例研究,进一步向读者讲述了Windows 2000的多线程操作、同步、进程间通信、安全性、虚拟存储管理及连网操作。...
    • Matlab常用函数集合,需要时方便查询
      Matlab常用函数集合,需要时方便查询
    • canny代码matlab-image_processing:数字图像处理
      canny代码matlab image_processing digital image processing 阈值处理 retval,otsu = cv2.threshold(grayscales,125,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU) 读取摄像头 cap = cv2.VideoCapture(0) ...cv2.Ca
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
      guassdb100在redhat上安装包,单机部署的包,安装步骤请看我的文中介绍,经过大量实验搭建总结出来的文档