Ask Your Question
1

Mat.step != IplImage.widthStep

asked 2013-09-10 00:22:37 -0600

updated 2016-01-04 12:18:47 -0600

Why are different the step of Mat with the widthStep of IplImgae ?

For an 3 channel image with width of 2806

Mat.step =8418

IplImage.widthStep = 8420

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2013-09-10 01:01:18 -0600

Michael Burdinov gravatar image

IPP (Intel Performance Primitives) library that was used as base of OpenCV project (that was started by Intel) performs much better when size of the object is multiple of 4 (or some other degree of 2). So in order to achieve better performance each row was 'padded' with few bytes. That was the original reason for introducing widthStep that is different from width. widthStep was not used for definition of ROI. ROI was one of the fields in IplImage object, but it was ignored by some algorithms, and this was reason for many bugs.

OpenCV 2 does not need this padding because it is not based on IPP anymore (well almost). But widthStep parameter was not removed. It is very simple to define ROI in image when width is not equal widthStep. Actually this way is much better than having ROI argument because algorithms that work with Mat don't need to check whether ROI is defined or not. And they can't ignore it. So ROI argument was removed, and widthStep argument remained. It is not used for padding anymore so 'step' equal 'width*channels'.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-09-10 00:22:37 -0600

Seen: 9,001 times

Last updated: Sep 10 '13