有关OpenCV的图像指针 本帖最后由 hikarutoto 于 2011-06-28 17:19:23 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 OpenCV的图像指针?Iplimage *? 灰度图的转换,拷贝一段给你参考。 IplImage * gray = cvCreateImage(cvSize(nWidth, nHeight), IPL_DEPTH_8U, 1); UCHAR * pData = (UCHAR*)malloc(sizeof(UCHAR) * nWidth * nHeight); for(int i = 0; i < nHeight; i++){ for(int j = 0; j < nWidth; j++){ *(pData + nWidth * (nHeight - 1 - i) + j) = (UCHAR)*(lpDIBBits + nWidth * (nHeight - 1 - i) + j); } } memcpy(gray->imageData, pData, nWidth * nHeight); 上面那个罗嗦了一点,实际上可以不需要UCHAR * pData = (UCHAR*)malloc(sizeof(UCHAR) * nWidth * nHeight);直接把*(pData + nWidth * (nHeight - 1 - i) + j) = (UCHAR)*(lpDIBBits + nWidth * (nHeight - 1 - i) + j);中的pData换成gray->imageData; IplImage*src=workImg;double *pix=new double[h*w];for(i=0;i<h;i++){ for(j=0;j<w;j++) { pixel=(unsigned char*)(src->imageData+i*w+j); pix[i*w+j]=*(pixel); }}pix_out[i*w+j]=pix[i*w+j]; txt文件回车丢失! //帮忙解释下下面代码详细点 求教:如何用VC环境运行一个新进程? 关于数据库一个很让我疑惑的问题 人生交叉点,请各位指点(实施/数据库开发) VC+sql sever+ado,如何判断如果一个数据表存在,则删除此表 类似安装程序的效果(点击下一步关闭当前界面并进入新一个界面,执行新的功能) 又是关于Release和Debug的问题!(是在搞不定了,请指教!) 请问哪里有mpeg文件编程的例子或文档? 如何进行写屏?有谁做过???? 愤怒 最简单的界面,但是注册失败
IplImage * gray = cvCreateImage(cvSize(nWidth, nHeight), IPL_DEPTH_8U, 1);
UCHAR * pData = (UCHAR*)malloc(sizeof(UCHAR) * nWidth * nHeight);
for(int i = 0; i < nHeight; i++){
for(int j = 0; j < nWidth; j++){
*(pData + nWidth * (nHeight - 1 - i) + j) =
(UCHAR)*(lpDIBBits + nWidth * (nHeight - 1 - i) + j);
}
}
memcpy(gray->imageData, pData, nWidth * nHeight);
实际上可以不需要UCHAR * pData = (UCHAR*)malloc(sizeof(UCHAR) * nWidth * nHeight);
直接把*(pData + nWidth * (nHeight - 1 - i) + j) =
(UCHAR)*(lpDIBBits + nWidth * (nHeight - 1 - i) + j);中的pData换成gray->imageData;
IplImage*src=workImg;
double *pix=new double[h*w];
for(i=0;i<h;i++)
{
for(j=0;j<w;j++)
{
pixel=(unsigned char*)(src->imageData+i*w+j);
pix[i*w+j]=*(pixel);
}
}
pix_out[i*w+j]=pix[i*w+j];