-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Hi CarVac,
I was trying to write a small test program to see how this raw processor works. However, after fumbling around for a few hours, I could not get the correct result. I must have done something wrong somewhere. Is there any guidance in this usage except the readme?
Here's what I did:
step 1: filling the cfa pattern array:
` unsigned cfa[2][2];
if (bayer_pattern == RGGB) {
cfa[0][0] = 0, cfa[0][1] = 1, cfa[1][0] = 1, cfa[1][1] = 2;
}else if (bayer_pattern == BGGR){
cfa[0][0] = 2, cfa[0][1] = 1, cfa[1][0] = 1, cfa[1][1] = 0;
}else if (bayer_pattern == GRBG) {
cfa[0][0] = 1, cfa[0][1] = 0, cfa[1][0] = 2, cfa[1][1] = 1;
};`
step 2: filling raw data
` int pixelsize = width * height;
/* AmAZeMEmE wants an image as floating points and 2d array as well */
const float ** restrict imagefloat2d = (const float **)malloc(height * sizeof(float *));
float * red1d = (float *)malloc(pixelsize * sizeof(float));
float ** restrict red2d = (float **)malloc(height * sizeof(float *));
float * green1d = (float *)malloc(pixelsize * sizeof(float));
float ** restrict green2d = (float **)malloc(height * sizeof(float *));
float * blue1d = (float *)malloc(pixelsize * sizeof(float));
float ** restrict blue2d = (float **)malloc(height * sizeof(float *));
/* AmAZe also wants to return floats, so heres memeory 4 it */
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int y = 0; y < height; ++y) {
imagefloat2d[y] = (const float *)(src + (y*width));
red2d[y] = (float *)(red1d + (y*width));
green2d[y] = (float *)(green1d + (y*width));
blue2d[y] = (float *)(blue1d + (y*width));
};
/* to do:
use multithreading to solve
*/
{
/* run the Amaze */
amaze_demosaic(width, height, 0, 0, width, height, imagefloat2d, red2d, green2d, blue2d, cfa, callback, 1.0, 0, 1.0f, 1.0f);
//rcd_demosaic(width, height,imagefloat2d, red2d, green2d, blue2d, cfa, callback);
};
/* Giv back as RGB, not separate channels */
for (int i = 0; i < pixelsize; i++)
{
int j = i * 3;
dst[j] = clip<uint32_t, T>((uint32_t)red1d[i]);
dst[j + 1] = clip<uint32_t, T>((uint32_t)green1d[i]);
dst[j + 2] = clip<uint32_t, T>((uint32_t)blue1d[i]);
}
`
Or even better, if there any document somewhere?