Ask Your Question

Revision history [back]

cvInitMatNDHeader in cvHistogram strange step sizes

I am trying to create a Histogram using the CreateHistogram funktion, so far so good.

When i checked into the memory there lies a flat CvMatND which in turn has a size and a step for each dimension.

As an example a 3D Mat with sizes of 5 results in (5,100,5,20,5,4).

Checking in the code the funktion goes like: (Cut out unimportant parts)

int64 step = CV_ELEM_SIZE(type); //step = get element size 
for( int i = dims - 1; i >= 0; i-- ) // running through all dims from the back
mat->dim[i].step = (int)step; // puts step into the Mat
step *= sizes[i]; //multiplies with size now

this is strange for 2 reasons.

  1. the last step is always the size of one element, this should imho definetly not be like that.
  2. the step grow, this CAN be correct if you define it so that the dimensions encompass all lower dimensions.

Is this a bug or does it have a deeper meanig i dont understand?