Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Efficient calculation with multiple cv::Mat

Hello, I need to do some math with my matrices and I would like to know the most performant way. I have the following vectors:

std::vector<cv::Mat> b //200 matrices with 1 row and 1000 elements per row
std::vector<cv::Mat> w //200 matrices with 1 row and 1000 elements per row 
std::vector <cv::Mat>image //200 matrices with 500 rows and 1000 elements per row

All vectors with the same index belong together. I need to calculate the following for every Mat of the vectors with the same index and every pixel in the image:

image(x, y) = (image(x,y) – b(x)) / (w(x) – b(x))  * 0,9

I would start like the following:

for(int i=0; i<image.size(); i++) 
{
//And here? 
//Usage of the β€œat”-method or pointer arithmetic?
//Or is there an operation which can calculate everything automatically line by line?
}

Thank you very much :-)