How to flip matrix in place?

asked 2016-06-24 16:23:04 -0500

goldroses gravatar image

updated 2016-06-24 16:24:07 -0500

I would like to reduce the 3 matrixes to just 2 matrixes by converting and flipping in one command, or flipping in place. Is there any way how to increase efficiency of the code?

cv::Mat dImg; // assume its initalized with TYPE_16UC1
cv::Mat dImg_grey;
cv::Mat dImg_grey_flip;
dImg.convertTo(dImg_grey, CV_8UC1, 255. / (2500 - 0), 0);//  to grayscale cv::Mat, (max - min)
cv::flip(dImg_grey, dImg_grey_flip, 1);// cannot flip in place

Is it somehow possible to stuff the flip into the convert.

edit retag flag offensive close merge delete

Comments

imho, you're worried in the wrong place, both operations are comparably cheap.

(and no, you can't flip in-place, and you can't combine them into a single operation.)

berak gravatar imageberak ( 2016-06-24 23:44:53 -0500 )edit