【发布时间】:2014-01-31 20:27:35
【问题描述】:
此代码用于8位数据制作灰度IplImage。
IplImage* img_gray_resize = NULL;
img_gray_resize = cvCreateImage(cvSize(320, 256), IPL_DEPTH_8U, 1);
DWORD dwCount;
LVDS_SetDataMode(0); // o for 8 bit mode and 1 for 16 bit mode
dwCount = (LONG)320 * (LONG)256;
unsigned char* m_pImage = NULL;
m_pImage = new unsigned char[320 * 256];
for (int i=0; i<320 * 256; i++) m_pImage[i] = NULL;
LVDS_GetFrame(&dwCount, m_pImage);
int width = 320;
int height = 256;
int nn = 0;
int ii = 0;
for (int y=0; y<height; y++)
{
for (int x=0; x<width; x++)
{
ii = y * width + x;
if(nn < (height*width))
img_gray_resize->imageData[ii] = m_pImage[nn++];
}
}
delete [] m_pImage;
我需要显示 16 位灰度图像。如果我显示 8 位数据,则图像中缺少一些信息。但是,LVDS_SetDataMode() 可以提供这两种类型的数据。我正在使用一个用于图像采集卡设备的库。请帮帮我。
【问题讨论】: