1 Star 0 Fork 0

Admin/marx_DisPAT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
getTrainingImage.m 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
marx 提交于 2021-11-26 19:53 . v1
% Ask the training image dimension
Dim = input('What is the training image dimension ? ') ;
Pat = input('What is the pattern dimension ? ') ;
% Read the training image
% [datain, colnames, line1]=loadgeoeas('ti2.dat');
% out = geoeas2matlab(datain,[Dim Dim]);
image=imread('ti.bmp');
image=imresize(image,[Dim Dim]);
image=im2bw(image,0.75);
out=1-image;
% show training image
% imagesc(out);
% if m=2 then every other pattern will be saved, if m=3 then 1st,4th,7th...
% will be recorded. And so on. (For reducing the dimension and redundancy).
m = input('Number of patterns to jump over in the series (Skipping) ? ');
m1 = input('Subsampling, distance between adjacent points (Multiple-Grids) ? ');
% Number of patterns : disDim*disDim
disDim = ceil((Dim - (1+(Pat-1)*m1) + 1)/m);
fprintf('\nPatterns retained for analysis = %d x %d\n\n', disDim,disDim);
X=[];
k=1;
for i=1:disDim
for j=1:disDim
%X((i-1)*disDim+j,:)=reshape(out(i:i+Pat-1,j:j+Pat-1),1,Pat^2);
wx = 1+m*(i-1):m1:1+m*(i-1)+(Pat-1)*m1;
wy = 1+m*(j-1):m1:1+m*(j-1)+(Pat-1)*m1;
% The "if" below is to delete completely empty patterns from calculations
% if sum(sum(out(wx,wy)))~=0
X(k,:)=reshape(out(wx,wy),1,Pat^2);
k=k+1;
% end
end
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/marx_1_1307066363/marx_-dis-pat.git
git@gitee.com:marx_1_1307066363/marx_-dis-pat.git
marx_1_1307066363
marx_-dis-pat
marx_DisPAT
master

搜索帮助