sub2ind在opencv中的等效功能 [英] equivalent function of sub2ind in opencv

查看:92
本文介绍了sub2ind在opencv中的等效功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在理解和将matlab代码转换为opencv时遇到了问题.我想知道sub2ind的等效功能是否与opencv中的matlab相同.或如何在opencv中实现此特定功能.

Iam facing problem in understanding and converting a matlab code into opencv. I want to know is there any equivalent function of sub2ind as in matlab in opencv. Or how to implement in opencv this particular function.

sub2ind函数的链接是

link for sub2ind function is

http://www.mathworks.in/help/techdoc/ref/sub2ind.html

推荐答案

一个简单的例子来说明.考虑:

A quick example to illustrate. Consider:

>> v = (1:4*3)
v =
     1     2     3     4     5     6     7     8     9    10    11    12
>> M = reshape(v,[4 3])
M =
     1     5     9
     2     6    10
     3     7    11
     4     8    12

现在以下所有内容都是等效的:

Now all the following are equivalent:

sz = size(M);

i = 3; j = 2;
M(i,j)
v( sub2ind(sz,i,j) )
v( sz(1)*(j-1)+i )

请记住,MATLAB使用列主序,而C是行主序.

Just keep in mind that MATLAB uses a column-major order, while C is row-major order

这篇关于sub2ind在opencv中的等效功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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