IplImage类型解释和举例
1.IplImage结构
typedef struct _IplImage {int nSize; /* sizeof(IplImage) */int ID; /* version (=0)*/int nChannels; /* Most of OpenCV functions support 1,2,3 or 4 channels */int alphaChannel; /* ignored by OpenCV */int depth; /* pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S,IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported */char colorModel[4]; /* ignored by OpenCV */char channelSeq[4]; /* ditto */int dataOrder; /* 0 - interleaved color channels, 1 - separate color channels.cvCreateImage can only create interleaved images */int origin; /* 0 - top-left origin,1 - bottom-left origin (Windows bitmaps style) */int align; /* Alignment of image rows (4 or 8).OpenCV ignores it and uses widthStep instead */int width; /* image width in pixels */int height; /* image height in pixels */struct _IplROI *roi;/* image ROI. if NULL, the whole image is selected */struct _IplImage *maskROI; /* must be NULL */void *imageId; /* ditto */struct _IplTileInfo *tileInfo; /* ditto */int imageSize; /* image data size in bytes(==image->height*image->widthStepin case of interleaved data)*/char *imageData; /* pointer to aligned image data */int widthStep; /* size of aligned image row in bytes */int BorderMode[4]; /* ignored by OpenCV */int BorderConst[4]; /* ditto */char *imageDataOrigin; /* pointer to very origin of image data(not necessarily aligned) -needed for correct deallocation */ } IplImage;2.pImgROI举例
nSize=0:sizeof(pImgROI)函数的结果,所以它总共占用了112个byte,不包含这一个帧整个的图像数据,而只是包含了pImgROI这个数据结构
整个帧的图像数据存放在imageData处,它所占用的空间大小可以这样来计算:
imageSize=762048=pImgROI->height * widthStep=672 * 2016
可以注意到 2016 = 3 * 672
我们可以知道 762048 = pImgROI->height * pImgROI->width * 3 (估计是通道数)
在设置了ROI的值之后,图像大小,width以及height也是完全没有发生变化的。
nChannels=3 :三通道图像
depth=8:参照cxtypes.h中的宏定义
#define IPL_DEPTH_1U 1 #define IPL_DEPTH_8U 8 #define IPL_DEPTH_16U 16 #define IPL_DEPTH_32F 32可知,这个帧采用了了IPL_DEPTH_8U类型,即无符号整形来存储一个点的像素信息。
origin=1:表示底左格式的图像,左下角是(0,0)点
roi:使用下面代码设置roi之后
cvSetImageROI(pImgROI,cvRect(x,y,w,h)); //cvSetImageROI的功能是基于给定的矩形设置图像的ROI(感兴趣区域)roi区域的值就发生变化
coi表示channel of interest (感兴趣的通道)
imageData:包含一个指向第一行图像数据的指针。
部分参考自《学习OpenCV》
另外,可以查阅http://blog.sciencenet.cn/home.php?mod=space&uid=297739&do=blog&id=251363
一下两个属性为个人臆测:
colorModel:说明这个是什么类型的图片,HSV,RGB,Gray,就是一个说明而已
channelSeq:说明了存储顺序,如图就是以B,G,R顺序存储
图片:
第(width-1)行 BGR BGR BGR BGR BGR
……
第三行 y=2 BGR BGR BGR BGR BGR
第二行 y=1 BGR BGR BGR BGR BGR
第一行 y=0 BGR BGR BGR BGR BGR
X=0 1 2 3 ……
转载于:https://www.cnblogs.com/jun14/archive/2013/01/14/2859520.html
总结
以上是生活随笔为你收集整理的IplImage类型解释和举例的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: C# 反射中的GetType
- 下一篇: Https与证书