|
各位大虾好,
我用MT9J001抓下来的图片看起来偏绿(见附件)
有试过通过R,G,Bgain来调整,可以改善,但是不能完全调到没有绿色,同时这样也引如另一个问题,R,G,B的值不一样了,我很难给用户提供一个gain调整的功能,比如我在redgain=100,bluegain=100时,为了改善偏绿的问题,调整greengain=80,但是当redgain=bluegain=200的时候,greengain又是不一样的值,可能是190这样子。。每个增益点对应的rgbgain都不样,gain调整功能就难做了,
也想过是不是bayer转换代码有问题,可是看起来好象没问题啊
这里假设:MT9J001的默认输出是GRBG的顺序
大虾帮我看下。。
/WX
image:
unsigned char * FormatConverter::BayerGRBG_To_RGB888_Bilinear(unsigned char *src)
{
quint8 *pSrcRow = src;
quint8 *pDstRow = m_buffer;
quint8 *pSrcRowNext = 0;
quint8 *pSrcRowPrev = 0;
long nSrcBytesPerRow = 1 * m_width;
long nDstBytesPerRow = 3 * m_width;
long nSrcWidth = m_width;
long nSrcHeight = m_height;
for (long nRow=0; nRow < nSrcHeight; nRow++) {
pSrcRowNext = pSrcRow + nSrcBytesPerRow;
if (nRow == 0) pSrcRowPrev = pSrcRowNext;
else pSrcRowPrev = pSrcRow - nSrcBytesPerRow;
if (nRow == nSrcHeight-1) pSrcRowNext = pSrcRowPrev;
for (long nCol = 0, k = 0; nCol < nSrcWidth; nCol++,k += 3) {
long nColNext = nCol + 1;
long nColPrev = nCol - 1;
if (nCol == 0) nColPrev = nColNext;
if (nCol == nSrcWidth-1) nColNext = nColPrev;
if ((nRow % 2) == 0) { // even row
if ((nCol %2) == 0) { // even column, Raw Green
pDstRow[k] = ((long)pSrcRow[nColNext] + pSrcRow[nColPrev])/2; // Red
pDstRow[k+1] = pSrcRow[nCol]; // green
pDstRow[k+2] = ((long)pSrcRowNext[nCol] + pSrcRowPrev[nCol])/2; // blue
} else { // // Raw Red
pDstRow[k] = pSrcRow[nCol]; // Red
pDstRow[k+1] = ((long)pSrcRow[nColPrev] + pSrcRow[nColNext] + pSrcRowNext[nCol] + pSrcRowPrev[nCol])/4; // Green
pDstRow[k+2] = ((long)pSrcRowNext[nColNext] + pSrcRowNext[nColPrev] + pSrcRowPrev[nColNext] + pSrcRowPrev[nColPrev]) / 4 ; // blue
}
} else { // odd row
if ((nCol % 2) == 0) { // odd column, Raw Blue
pDstRow[k] = ((long)pSrcRowNext[nColNext] + pSrcRowNext[nColPrev] + pSrcRowPrev[nColNext] + pSrcRowPrev[nColPrev]) / 4 ; // Red
pDstRow[k+1] = ((long)pSrcRow[nColPrev] + pSrcRow[nColNext] + pSrcRowNext[nCol] + pSrcRowPrev[nCol])/4; // Green
pDstRow[k+2] = pSrcRow[nCol]; // blue
} else { // Raw Green
pDstRow[k] = ((long)pSrcRowNext[nCol] + pSrcRowPrev[nCol])/2; // Red
pDstRow[k+1] = pSrcRow[nCol]; // Green
pDstRow[k+2] = ((long)pSrcRow[nColNext] + pSrcRow[nColPrev])/2; // blue
}
}
}
pSrcRow += nSrcBytesPerRow;
pDstRow += nDstBytesPerRow;
}
return m_buffer;
} |
|