Matlab中的此功能是什么? [英] What is this function in Matlab?

查看:69
本文介绍了Matlab中的此功能是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以详细告诉我此功能的每一行是什么吗?

Can someone tell me in detail what each line does of this function?

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];

谢谢.

推荐答案

所以我想我也已经弄清楚了.看起来图像被表示为6个矢量,其中包含颜色,纹理和位置数据.因此,样本图像的输入是一个表示图像的Mx6数组. DatabaseImage包含许多这些矢量表示形式

So I think I've figured this one out as well. It would appear that the images are represented as 6 vectors which hold color, texture and position data. So the input of sample image is an Mx6 array which represents an image. The DatabaseImage holds a number of these vector representations

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];

这篇关于Matlab中的此功能是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆