这个函数在Matlab中是什么?

时间:2014-05-07 14:21:14

标签: matlab

有人可以详细告诉我这一功能的每一行吗?

function [out]=Compare(SampleImage,DatabaseImage)
nCol=(3+1+2);
colourN=[];textureN=[];positionN=[];
for times=1:size(DatabaseImage,2)/nCol
    sp=nCol*(times-1);
    colourN = [colourN norm(SampleImage(:,1:3)-DatabaseImage(:,sp+1:sp+3))];
    textureN=[textureN norm(SampleImage(:,4)-DatabaseImage(:,sp+4))];
    positionN=[positionN norm(SampleImage(:,5:6)-DatabaseImage(:,sp+5:sp+6))];
end
out=[colourN;textureN;positionN];

谢谢。

1 个答案:

答案 0 :(得分:1)

所以我觉得我也想出了这个。看起来图像被表示为6个矢量,其保持颜色,纹理和位置数据。因此,样本图像的输入是表示图像的Mx6阵列。 DatabaseImage包含许多这些矢量表示

function [out]=Compare(SampleImage,DatabaseImage)
% //define the 6 columns, and initialize some empty arrays
nCol=(3+1+2); % //input appears to be a 6 band vector image ie Mx6
colourN=[];textureN=[];positionN=[];

% //for 1 to number of cols in DatabaseImage / nCol
% //This will be the number of images in DatabaseImage. 
% //so this loop loops over each database vector image
for times=1:size(DatabaseImage,2)/nCol
    % //zero-based index of the first column of the current image
    sp=nCol*(times-1);

    % //this will be the "distance" between the two values in terms of color, texture and position
    % //append each of these to the end of the array. 
    colourN = [colourN norm(SampleImage(:,1:3)-DatabaseImage(:,sp+1:sp+3))];
    textureN=[textureN norm(SampleImage(:,4)-DatabaseImage(:,sp+4))];
    positionN=[positionN norm(SampleImage(:,5:6)-DatabaseImage(:,sp+5:sp+6))];
end

% // then append along the other dimension to output as one matrix
out=[colourN;textureN;positionN];