What is IplImage
in OpenCV
? Can you just explain what is meant by it as a type? When should we use it?
Thanks.
Based on the 'c++' tag you have in your question: You should not use it, you should use cv::Mat. Every IplImage is a cv::Mat internally.
IplImage is only used in the C API. It is a kind of CvMat and holds image data. Its name originates from OpenCV's roots (Intel IPL).
It is not relevant anymore if you use the C++ API of OpenCV.
IplImage and cv::Mat are different header types for matrix/image data. They're basically compatible with each other, but IplImage is used in OpenCV's C API, while cv::Mat is used in the new C++ API.
When you decide to use OpenCV's C API, you will mostly use IplImages. Otherwise you will mostly use cv::Mats.
Of course, you can convert IplImages and cv::Mats to each other, e.g.
cv::Mat mat(myIplImage);
In this case, they share the same underlying data, i.e. modifications made through either header will be visible regardless of what header you're using to access the data.
Deep-copy (not only header is "transformed"/copied, but also the underlying data) is possible with
cv::Mat mat(myIplImage, true)
Note that multiple IplImages can also point to the same underlying data, as can multiple cv::Mats.
When working with OpenCV and similar libraries it is important to notice that cv::Mats and IplImages are only "headers" for the actual data. You could say that cv::Mats and IplImages are basically pointers plus important meta information like number of rows, columns, channels and the datatype used for individual cells/pixels of the matrix/image. And, like real pointers, they can reference/point to the same real data.
For example, look at the definition of IplImage: http://opencv.willowgarage.com/documentation/basic_structures.html#iplimage
The most important member is char *imageData;
. This pointer references the actual image data. However, the IplImage as a whole contains meta information about the image as well, like number of rows and columns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With