Opencv中将CvMat转为IplImage,并在内存获得起头指针,而不用cvSaveImage(),贴上代码
IplImage * imgg = NULL;
imgg = cvCreateImage(cvSize(modelF[].Matrix->cols,modelF[].Matrix->rows),IPL_DEPTH_8U,); float ve;
for(int n = ; n < modelF[].Matrix->rows; n++){
for(int m = ; m < modelF[].Matrix->cols; m++){
ve = CV_MAT_ELEM(*(modelF[].Matrix),float,n,m);
CV_IMAGE_ELEM(imgg,uchar,n,m) = (uchar)cvRound(ve);
}
}
cvNamedWindow("imgg",CV_WINDOW_AUTOSIZE);
cvShowImage("imgg",imgg);
cvWaitKey(0);
注意这里的cvSize类的用法,cvSize(int width,int height) 是先输入图像矩阵的列,再输入行