Mat.step != IplImage.widthStep
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
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
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'.
Asked: 2013-09-10 00:22:37 -0600
Seen: 9,001 times
Last updated: Sep 10 '13
Saving an image with unset pixels
C++ map with <cv::Mat, IplImage*> key-value format
Access multiple channels in Mat
Converting Mat to IplImage in Java
converting from iplimage to cvmat and vise versa
How convert blob/binary data to Mat
What is the most effective way to access cv::Mat elements in a loop?