图像聚类-matlab函数的问题
目前我正在写一个关于图像识别和聚类的项目。在作为我的项目基础的出版物中,有这个方程
下面给出了变量描述
Rj - 是第 j 个旋转矩阵 集群
t_j - 是第 j 个的平移向量 集群
p*ij - 是第 j 个点中的第 i 个点 集群
x_i - 是图像中的第 i 个点
我在编写这个函数时遇到了一些问题,所以我询问出版物的作者是否可以与我分享源代码。这是我得到的
ddx=D.x-Q.translation(1);
ddy=D.y-Q.translation(2);
st=sin(Q.theta); ct=cos(Q.theta); R=[ct -st; st ct]; % rotation matrix
qq=R*[ppx0; ppy0];
qqd2=sum(qq.*qq,1);
Q.scale=sum((ddx.*qq(1,:)+ddy.*qq(2,:)).*Um) / sum(qqd2.*Um);
的坐标。
Dx
和 Dy
是数据点Q.translation
(向量)、Q.translation
scale 和 Q.theta
是变换参数
ppx0
和 ppy0
是 x- 和*p**ij 的 y- 坐标
Um
是包含 [U 的矩阵mij]
但是我很难理解这个解决方案。首先,我不明白为什么他使用数组乘法(运算符.*
)而不是矩阵乘法(运算符*
),而且他似乎只需要一个/first point p*
我希望有人能帮助我尝试这个源代码。提前致谢
Curently I'm writing a project about image recognition and clusterization. In publication which is a basis for my project there is this equation
Variables description is given below
Rj - is a rotation matrix of j-th
clustert_j - is a translation vector of j-th
clusterp*ij - is a i-th point from j-th
clusterx_i - is a i-th point from the image
I had a little problem with writing this function so I asked the author of publication if he could share with me a source code. Here is what I got
ddx=D.x-Q.translation(1);
ddy=D.y-Q.translation(2);
st=sin(Q.theta); ct=cos(Q.theta); R=[ct -st; st ct]; % rotation matrix
qq=R*[ppx0; ppy0];
qqd2=sum(qq.*qq,1);
Q.scale=sum((ddx.*qq(1,:)+ddy.*qq(2,:)).*Um) / sum(qqd2.*Um);
Here D.x
, and D.y
are the coordinates of data points
Q.translation
(a vector), Q.scale
, and Q.theta
are the transform parameters
ppx0
and ppy0
are the x- and y- coordinates of *p**ij
Um
is the matrix containing [Umij]
However I have a hard time with understanding this solution. First of all I don't understand why he uses array multiplication (operator .*
) instead of matrix multiplication (operator *
) what is more it seems that he takes only one/first point p*
I hope somebody will help me to try this source code. Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来
ppx0
和ppy0
不是坐标,而是向量或坐标。这样,qq
就是一个 2xN 向量,就像[ppx0; ppy0]
。在
qqd2=sum(qq.*qq,1)
中,使用了.*
运算符,因为您实际上是对矩阵的每个值进行平方来求平方距离稍后它的每个坐标对。在 ddx.*qq(1,:)+ddy.*qq(2,:) 中,
.*
运算符用作替换双精度和的快捷方式。换句话说,它们不是单独对每个矩阵乘积求和(其本身就是乘法之和),而是首先执行所有必要的乘法,然后求和。 (我希望这是有道理的)。您可以使用一些基本的矩阵代数来证明所有这些工作。it looks like
ppx0
andppy0
are not coordinates, but rather vectors or coordinates. This way,Therefore
qq
is a 2xN vector, just like[ppx0; ppy0]
.In
qqd2=sum(qq.*qq,1)
, the.*
operator is used, because you're actually squaring every value of a matrix to find the square distance of each of its coordinate pairs later on.In
ddx.*qq(1,:)+ddy.*qq(2,:)
the.*
operator is used as a shortcut to replace a double sum. In other words, istead of taking a sum of each matrix product individually (which in itself is a sum of multiplication), they first performed all necessary multiplications and then took a sum. (I hope this makes sense). You can prove all of these work with some basic matrix algebra.