[OpenCV 학습] step 의 응용

1652 단어 opencv
저자: gnuhpc 출처: http://www.cnblogs.com/gnuhpc/
#pragma comment(lib,"cxcore.lib")
#include"cv.h"
#include<stdio.h>
int main()
{
 //        8    
    CvMat *mat=cvCreateMat(3,3,CV_32FC3 );
    float *p;
    int row,col;
    for(row=0; row< mat->rows; row++)
    {
        p = mat->data.fl + row * (mat->step/4);
        /*   4     float 4   ,  double   8,uchar  */
        for(col = 0; col < mat->cols; col++)
        {
            *p = (float) row+col;
            *(p+1) = (float) row+col+1;
            *(p+2) =(float) row+col+2;
            p+=3;
        }
    }
    
    for(row = 0; row < mat->rows; row++)
    {
        p = mat->data.fl + row * (mat->step/4);
        for(col = 0; col < mat->cols; col++)
        {
            printf("%f,%f,%f/t",*p,*(p+1),*(p+2));
            p+=3;
        }
        printf("/n");
    }

    printf("rows=%d,cols=%d,height=%d,width=%d,step=%d/n",mat->rows,mat->cols,mat->height,mat->width,mat->step);

    return 0;
}

 
저자: gnuhpc 출처: http://www.cnblogs.com/gnuhpc/

좋은 웹페이지 즐겨찾기