作业帮 > 综合 > 作业

谁能帮我解释一下这个matlab的语句?

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/20 03:45:34
谁能帮我解释一下这个matlab的语句?
tic;
close all;
clear;
clc;
format compact;
%%
pic = imread('C:\Users\xll\Desktop\littleduck.jpg');
% figure;
% imshow(pic);
[m,n,k] = size(pic);
% data = zeros(m*n,5);
data(1:m*n,1:3) = double(reshape(pic,m*n,k));
% for i = 1:n
% data((i*m-m+1):i*m,k+1) = (1:m)';
% data((i*m-m+1):i*m,k+2) = i*ones(1,m);
% end
options = [2 200 1e-5 0];
cluster_n = 3;
[center,U,obj_fcn] = fcm(data,cluster_n,options);
cluster = cell(1,cluster_n);
cluster_pic = cell(1,cluster_n);
pic = cell(1,cluster_n);
for i = 1:cluster_n
cluster{i} = find( U(i,:)==max(U));
cluster{i} = cluster{i}';
cluster_pic{i} = data(1:m*n,1:3);
temp = data(1:m*n,1:3);
temp(cluster{i},:) = 0;
cluster_pic{i} = cluster_pic{i}-temp;
pic{i} = reshape(cluster_pic{i},m,n,k);
figure;
imshow(uint8(pic{i}));
end
%%
toc;
谁能帮我解释一下这个matlab的语句?
tic是打开一个计时器,最后一行的toc关闭计时器,第一行和最后一行就是对这段程序计时用的.然后是清除变量(在运行这段程序之前你最好保存好先前的变量,否则会被删除掉),imread()读入地址上的图片()到pic,其实图片就是一个三维矩阵,size(pic)求取图片矩阵的大小.reshape()对pic矩阵进行变型(改变维数),并保存成double类型数据.然后使用fcm()处理data,具体怎么处理你这里没有给出,请你查看fcm函数吧.