Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

IplImage in OpenCV

📅 2014-Feb-21 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ iplimage, mat, opencv ⬩ 📚 Archive

You might run into the IplImage structure while looking at OpenCV code. It is an old structure that is present from the days when OpenCV was called Intel Processing Library, hence IPL.

The different members of IplImage and their descriptions can be found here. The declaration of IplImage can be found in modules/core/include/opencv2/core/types_c.h of the OpenCV source code, as can be seen here.

The basic structure of IplImage is:

#define IPL_DEPTH_1U     1
#define IPL_DEPTH_8U     8
#define IPL_DEPTH_16U   16
#define IPL_DEPTH_32F   32
#define IPL_DEPTH_SIGN 0x80000000
#define IPL_DEPTH_8S  (IPL_DEPTH_SIGN| 8)
#define IPL_DEPTH_16S (IPL_DEPTH_SIGN|16)
#define IPL_DEPTH_32S (IPL_DEPTH_SIGN|32)

struct IplImage
{
    int depth; // Datatype of pixel (see above)
    int nChannels; // 1, 2, 3 or 4
    int width;
    int height;
    char* imageData;
    int widthStep;
};

Constructing it is easy:

IplImage* img = cvCreateImage(cvSize(200, 200), IPL_DEPTH_32F, 1); // 1-channel float image

The modern Mat structure in OpenCV is preferable to using IplImage. IplImage can be converted to Mat as described here.


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧