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]
Don't use integers to perform division. Instead, convert your Mat to another type such as double or float, perform division and then re-convert to integer (is you need integers at the end) through operations like round, ceil or floor.