OpenCV:widthStep vs step( 二 )


    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;                 /* "           " */
    struct _IplTileInfo *tileInfo;  /* "           " */
    int  imageSize;  /* Image data size in bytes (==image->height*image->widthStep in 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;

OpenCV:widthStep vs step



3IplImage*拜候图像像素:widthStep
对8bit , 单通道 , unsigned char类型的图像I---IplImage* img:
I(x, y)~((unsigned char*)(img->imageData+img->widthStep*y))[x];
对8bit , 3通道 , unsigned char类型的图像I---IplImage* img:
I(x, y)blue~((unsigned char*)(img->imageData+img->widthStep*y))[x*3];
I(x, y)green~((unsigned char*)(img->imageData+img->widthStep*y))[x*3+1];
I(x, y)red~((unsigned char*)(img->imageData+img->widthStep*y))[x*3+2];

猜你喜欢