if (m_iImageIndex < m_option->m_uImageCount)
{
ushort *pusTempImage = (ushort *)image;
for (int i = 0; i < m_FrameParam.Height * m_FrameParam.Width; i++)
{
m_usImage[i] += pusTempImage[i];
}
m_iImageIndex++;
if (m_iImageIndex < m_option->m_uImageCount)
{
return ERR_Continue;
}
}
for (int i = 0; i < m_FrameParam.Height * m_FrameParam.Width; i++)
{
m_usImage[i] = (m_usImage[i] / m_option->m_uImageCount) & 0xffff;
}
int width = m_FrameParam.Width;
int height = m_FrameParam.Height;
const int BLC = 64;
if (0)
{
unsigned short *pPixelValue = (unsigned short *)m_usImage;
// GRBG
FILE *pfGr = fopen("0_pixel_Gr.csv", "w");
FILE *pfR = fopen("0_pixel_R.csv", "w");
FILE *pfB = fopen("0_pixel_B.csv", "w");
FILE *pfGb = fopen("0_pixel_Gb.csv", "w");
for (int i = 0; i < height; i += 2)
{
for (int j = 0; j < width; j += 2)
{
fprintf(pfGr, "%d,", pPixelValue[i * width + j] - BLC);
fprintf(pfR, "%d,", pPixelValue[i * width + j + 1] - BLC);
fprintf(pfB, "%d,", pPixelValue[(i + 1) * width + j] - BLC);
fprintf(pfGb, "%d,", pPixelValue[(i + 1) * width + j + 1] - BLC);
}
fprintf(pfGr, "\n");
fprintf(pfR, "\n");
fprintf(pfB, "\n");
fprintf(pfGb, "\n");
}
fclose(pfGr);
fclose(pfR);
fclose(pfGb);
fclose(pfB);
}
{
//4个通道
int *pChannel1 = new int[width / 2 * height / 2];
int *pChannel2 = new int[width / 2 * height / 2];
int *pChannel3 = new int[width / 2 * height / 2];
int *pChannel4 = new int[width / 2 * height / 2];
unsigned short *pPixelValue = (unsigned short *)m_usImage;
int idx = 0;
for (int i = 0; i < height; i += 2)
{
for (int j = 0; j < width; j += 2)
{
pChannel1[idx] = pPixelValue[i*width + j] - BLC;
pChannel2[idx] = pPixelValue[i*width + j + 1] - BLC;
pChannel3[idx] = pPixelValue[(i + 1)*width + j] - BLC;
pChannel4[idx] = pPixelValue[(i + 1)*width + j + 1] - BLC;
idx++;
}
}
{
int block_w = (width / 2) / 17;
int block_h = (height / 2) / 13;
int col_17_block_w = (width / 2) / 17 + (width / 2) % 17;
int row_13_block_h = (height / 2) / 13 + (height / 2) % 13;
// row,行;column,列;
for (size_t r = 0; r < 13; r++)
{
for (size_t c = 0; c < 17; c++)
{
int w = (c != 16) ? block_w : col_17_block_w;
int h = (r != 12) ? block_h : row_13_block_h;
int ichannel_1 = 0, ichannel_2 = 0, ichannel_3 = 0, ichannel_4 = 0;
int pixelCount = 0;
for (size_t i = 0; i < h; i++)
{
for (size_t j = 0; j < w; j++)
{
int x = c * block_w + j;
int y = r * block_h + i;
int index = y * (width / 2) + x;
ichannel_1 += pChannel1[index];
ichannel_2 += pChannel2[index];
ichannel_3 += pChannel3[index];
ichannel_4 += pChannel4[index];
pixelCount++;
}
}
m_dChannel_1[r * 17 + c] = (double)ichannel_1 / pixelCount;
m_dChannel_2[r * 17 + c] = (double)ichannel_2 / pixelCount;
m_dChannel_3[r * 17 + c] = (double)ichannel_3 / pixelCount;
m_dChannel_4[r * 17 + c] = (double)ichannel_4 / pixelCount;
}
}
}
}