image_to_matrix.m

来自「kmeans clustering in matlab」· M 代码 · 共 25 行

M
25
字号
function [imatrix, index] = image_to_matrix(data)%% converts an array structure of the form data(:,:).image% to an n x d matrix, where each row is a raster-vector% representation of data(:,:).image.[m n] = size(data);[nx ny] = size(data(1,1).image);
count = 1;
for i=1:m   for j=1:n      [inx iny] = size(data(i,j).image);      if inx==nx & iny==ny            imatrix(count,:) = reshape(data(i,j).image, 1, nx*ny);            index(count,1) = i;            index(count,2) = j;            count = count + 1;    	end               endend
fprintf('%d images in total\n',count-1);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?