Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
49 Views

Fastest way to do CFA->RGB Conversion

Hi experts,

 

Filters and Convolutions works well and much faster than my code with AVX2.

So I have decided to use some IPP functions but, color conversion seems like not easy...

 

So I'm trying to find a fastest way to convert CFA Conversion.

(separating colors. like 1 CFA Image to 4 RGGB Image)

Not only bayer, I have different kind of  formats to be transformed.

 

I tried "ippiCFAToBGRA_VNG_16u_C1C4R" for bayer, too slow even in parallel with omp.

So I tried to make some combinations of RoiShift and AND(OR) and

it takes about 50ms per image with i7-7700 to convert 24M Pixel Image.

I'm not still satisfied with the result, hopefully I can shrink this in half.

 

The pixel values are 16bit so "Ipp16u" is type of original image.

 

0 Kudos
3 Replies
Highlighted
Employee
36 Views

Hi Joseph!

Could you try please combination

ippiCFAToRGB_16u_C1C3R+ippiCopy_16u_C3AC4R?

Thanks.

0 Kudos
Highlighted
Beginner
29 Views

Hi Andrey,

 

I tried run ippiCFAToRGB_16u_C1C3R+ippiCopy_16u_C3AC4R,

before checking the performance,


IppiSize szDst = { Width, Height };
IppiRect Rect1 = { 0, 0, Width, Height };

pSrc[0] = 1;
pSrc[1] = 2;
pSrc[2] = 3;
pSrc[3] = 4;
pSrc[0 + szDst.width] = 5;
pSrc[1 + szDst.width] = 6;
pSrc[2 + szDst.width] = 7;
pSrc[3 + szDst.width] = 8;

 

// 1 2 3 4

// 5 6 7 8

// left top should be like above.

 

ippiCFAToRGB_16u_C1C3R((const Ipp16u*)pSrc, Rect1 , szDst8, cStep, (Ipp16u*)pDst2, cStep, ippiBayerBGGR, 0);
ippiCopy_16u_C3AC4R((const Ipp16u*)pDst2, cStep / 2, (Ipp16u*)pDst3, cStep, szDst);

 

and I checked the pDst3, doesn't looke like C4R...

what is expected matrix values on pDst3 in this case?

I got pDst3[0] =6, pDst3[1] =4, pDst3[2] =1,  pDst3[3] =0,  pDst3[4] =6,  pDst3[5] =2,  pDst3[6] =2 and so on .

 

Thank you

Joseph.

0 Kudos
Highlighted
Employee
21 Views

Hi.

C3 means 3 channels, AC4- means 4(3 color and 1 alpha), i.e.

pSrc - RGB(3 channels)

pSrc[0] = 1;
pSrc[1] = 2;
pSrc[2] = 3;
pSrc[0 + szDst.width] = 4;
pSrc[1 + szDst.width] = 5;
pSrc[2 + szDst.width] = 6;

pDst (4 channels, 3RGB+alpha)

pDst = malloc()

pDst[0] = 7;
pDst[1] = 8;
pDst[2] = 9;
pDst[3] = xx;
pDst[0 + szDst.width] = 10;
pDst[1 + szDst.width] = 11;
pDst[2 + szDst.width] = 12;
pDst[3 + szDst.width] = yy;

after ippiCopy_16u_C3AC4R(pSrc,..,pDst)

pDst will be

pDst[0] = 1;
pDst[1] = 2;
pDst[2] = 3;
pDst[3] = xx;
pDst[0 + szDst.width] = 4;
pDst[1 + szDst.width] = 5;
pDst[2 + szDst.width] = 6;
pDst[3 + szDst.width] = yy;

Check please if all pointers and srcStep/dstStep are correct because steps in bytes, not elements.

Thanks  

0 Kudos