这个函数在matlab中做什么?
有人能详细地告诉我每一行的功能是什么吗?另外,我不知道“rangefilt”是做什么的。当通过GUI发送图像路径时,将调用下面的代码这个函数在matlab中做什么?,matlab,Matlab,有人能详细地告诉我每一行的功能是什么吗?另外,我不知道“rangefilt”是做什么的。当通过GUI发送图像路径时,将调用下面的代码 function [imC]=training(imPath) im=imread(imPath); x = 75; y = 75; reSim=imresize(im,[x,y]); textureim=rangefilt(rgb2gray(reSim)); p=cat(3,reSim,textureim); xi=[1:1:x]';
function [imC]=training(imPath)
im=imread(imPath);
x = 75;
y = 75;
reSim=imresize(im,[x,y]);
textureim=rangefilt(rgb2gray(reSim));
p=cat(3,reSim,textureim);
xi=[1:1:x]';
mi=repmat(xi, [1 y]);
yj=[1:1:y];
mj=repmat(yj,[x 1]);
mp=cat(3,mi,mj);
fp=cat(3,p,mp);
[pox poy poz]=size(fp);
pon=pox*poy;
vecim = reshape(fp,pon,poz);
[temp imC]=kmeans(double(vecim),5);
谢谢。虽然有人已经回答了,但我想敦促你至少自己试着找出尽可能多的台词。对于这样的问题,这种努力的表现是最低限度的。我喜欢这个答案。一旦你感到足够自信,这些类型的问题是一个很好的机会,教新用户提出更好的问题,正如我在上面的评论中所做的那样。希望这能改善他们的问题和用户体验。你能解释一下这个问题吗?如果这个主题已经结束,请将问题标记为
function [imC]=training(imPath)
% //read in the image
im=imread(imPath);
% //Resize the image to be 75x75
x = 75;
y = 75;
reSim=imresize(im,[x,y]);
% // use rangefilt on a grayscale version
% //rangefilt returns (max-min) for each pixel of a 3x3 neighborhood
textureim=rangefilt(rgb2gray(reSim));
% //reshape them into two bands of p
p=cat(3,reSim,textureim);
% //These 4 lines are like meshgrid, create a vector, then repmat it into an image
xi=[1:1:x]'; % //'
mi=repmat(xi, [1 y]);
yj=[1:1:y];
mj=repmat(yj,[x 1]);
% // concatenate along third dimension (so we have another 2 band image)
mp=cat(3,mi,mj);
% //now we should have 4 bands, resim,textureim,mi,mj
fp=cat(3,p,mp);
% //get the size in x,y,z
[pox poy poz]=size(fp);
% //calculate the number of pixels in each band
pon=pox*poy;
% //reshape it to poz vectors of length pox*poy
vecim = reshape(fp,pon,poz);
% //run kmeans on the data which will cluster based on intensity, texture and position
[temp imC]=kmeans(double(vecim),5);