Are there any functions in OpenCV which are equal to MATLAB's sub2ind
and ind2sub
functions? I need both functions for my C++ app.
If OpenCV lacks of these functions, are there any C++ libs which provide equivalent functionality?
You can write them yourself:
int sub2ind(const int row,const int col,const int cols,const int rows)
{
return row*cols+col;
}
void ind2sub(const int sub,const int cols,const int rows,int &row,int &col)
{
row=sub/cols;
col=sub%cols;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With