Working with aligned rows

asked 2014-02-10 03:21:59 -0600

Pibben gravatar image

To speed up calculations I want the rows of cv::Mat to be aligned at 64-bit.

Here is how I do it now:

Construction:

int padded = ((width-1) & -64) + 64;
cv::Mat tmp = cv::Mat::zeros(height, padded, CV_8U);
cv::Mat mat = tmp.colRange(0, width);

Creation:

int padded = ((width-1) & -64) + 64;
mat.create(height, padded, CV_8U);
mat.adjustROI(0, 0, 0, width-padded);

I also noticed that push_back() does not keep the old step size, so I had to do a workaround for that as well. What are your tips for working with aligned rows?

edit retag flag offensive close merge delete