此代碼用於8位數據製作灰度IplImage。如何使16位灰度數據的OpenCV 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()可以提供這兩種類型的數據。我正在使用圖像採集卡設備庫。請幫幫我。
如何將16位數據轉換爲8位數據?請給我一些信息。 – IRFAN
1.計算對16位圖像的hisgram尊重2.將它規範化爲prob並轉換爲cdf 3.將具有值cdf的索引映射到256 * cdf – michaeltang