Ask Your Question

Revision history [back]

Is there a way to prevent rounding in opencv matrix divison

I have an integer matrix and I want to perform an integer division on it. But opencv always rounds the result. I know I can divide each element manually but I want to know is there a better way for this or not?

Mat c = (Mat_ <int> (1,3) << 80,71,64 );
cout << c/8 << endl;

// result
//[10, 9, 8]

// desired result
//[10, 8, 8]

Is there a way to prevent rounding in opencv matrix divison

I have an integer matrix and I want to perform an integer division on it. But opencv always rounds the result. I know I can divide each element manually but I want to know is there a better way for this or not?

Mat c = (Mat_ <int> (1,3) << 80,71,64 );
cout << c/8 << endl;

// result
//[10, 9, 8]

// desired result
//[10, 8, 8]