Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

When you create CvMat* e with cvGetSubRect you only create a matrix header which means matrix b is not copied and e points to the memory location of b. Your dereferences in cout point to the memory locations following the starting memory position of b.

Your expected result can be achieved like this (I assume older OpenCV version): CV_MAT_ELEM(e, float, 0, n) with n=0,1,2,3.