Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Need help on ippiCrossCorrSame_NormLevel

tsdmilan
Beginner
315 Views
Dear all,
I experienced some very strange behavior when using the ippiCrossCorrSame_NormLevel() function on 4-channel image. It seems to fail to compute the correlation coefficients for the B-channel. The following is the code:
#define WIDTH 384
#define HEIGHT 288
#define TEMPLATE_WIDTH 32
#define TEMPLATE_HEIGHT 32
#define PATTERN_LEFT ((WIDTH - TEMPLATE_WIDTH) / 2)
#define PATTERN_TOP ((HEIGHT - TEMPLATE_HEIGHT) / 2)
#define PATTERN_WIDTH 32
#define PATTERN_HEIGHT 32
#define PATTERN_X (PATTERN_LEFT + PATTERN_WIDTH / 2)
#define PATTERN_Y (PATTERN_TOP + PATTERN_HEIGHT / 2)
int main(int argc, char* argv[])
{
int WidthStep;
IppiSize Size = {WIDTH, HEIGHT};
Ipp8u *pFrame = ippiMalloc_8u_AC4(WIDTH, HEIGHT, &WidthStep);
Ipp8u Black[3] = {0};
ippiSet_8u_AC4R(Black, pFrame, WidthStep, Size);
int TemplateWidthStep;
IppiSize TemplateSize = {TEMPLATE_WIDTH, TEMPLATE_HEIGHT};
Ipp8u *pTemplate = ippiMalloc_8u_AC4(TEMPLATE_WIDTH, TEMPLATE_HEIGHT, &TemplateWidthStep);
// generate a random pattern and assign it to the template
int i, j, k;
for (j = 0; j < TEMPLATE_HEIGHT; ++j)
{
for (i = 0; i < TEMPLATE_WIDTH; ++i)
{
for (k = 0; k < 4; ++k)
{
if (k < 3)
pTemplate[j * TemplateWidthStep + i * 4 + k] = rand() % 256;
else
pTemplate[j * TemplateWidthStep + i * 4] = 0;
}
}
}
// copy the random pattern to the middle of the image
ippiCopy_8u_AC4R(pTemplate, TemplateWidthStep, pFrame + PATTERN_TOP * WidthStep + PATTERN_LEFT * 4, WidthStep, TemplateSize);
int CorrWidthStep;
Ipp32f *pCorr = ippiMalloc_32f_AC4(WIDTH, HEIGHT, &CorrWidthStep);
IppiSize TplSize = {PATTERN_WIDTH, PATTERN_HEIGHT};
IppStatus Status = ippiCrossCorrSame_NormLevel_8u32f_AC4R(pFrame, WidthStep, Size,
pTemplate, TemplateWidthStep, TplSize,
pCorr, CorrWidthStep);
Ipp32f MaxScore_C3[3];
int Index_X[3], Index_Y[3];
ippiMaxIndx_32f_AC4R(pCorr, CorrWidthStep, Size, MaxScore_C3, Index_X, Index_Y);
double MaxScore = .0;
for (int c = 0; c < 3; ++c)
MaxScore += MaxScore_C3;
MaxScore /= 3.0;
char Temp[1024];
sprintf(Temp, "MaxScore = %.4lf at B: (%d,%d), G: (%d,%d), R: (%d,%d)", MaxScore,
Index_X[0], Index_Y[0], Index_X[1], Index_Y[1], Index_X[2], Index_Y[2]);
cout << Temp << endl;
// print the correlation coefficients at the center pixel
for (k = 0; k < 4; ++k)
cout << "k = " << k << ": " << pCorr[PATTERN_Y * (CorrWidthStep / 4) + PAT TERN_X * 4 + k] << endl;
ippiFree(pFrame);
ippiFree(pTemplate);
ippiFree(pCorr);
return 0;
}
And the result output:
MaxScore = 0.6667 at B: (0,0), G: (192,144), R: (192,144)
k = 0: 0 // correlation coefficient for B-channel (why zero?)
k = 1: 1 // correlation coefficient for G-channel
k = 2: 1 // correlation coefficient for R-channel
k = 3: 0 // alpha channel not used
I wonder if I have missed something or what.
Regards,
Milan

0 Kudos
2 Replies
Vladimir_Dudnik
Employee
315 Views

Hello Milan,

Our records show that there was a bug like this in previous IPP version. Did you use the latest IPP version, v5.1?

Regards,
Vladimir

0 Kudos
tsdmilan
Beginner
315 Views

Hello vdudnik,

You're right. We are still using IPP 5.0. Thanks for the confirmation of the bug.

Best regards,

Milan.

0 Kudos
Reply