- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
i'm quite new to the IPP and tried to write a little
program for testing ippiMatchTemplate, but the output of
the program is not what i expected. I think it has
to be 3 by 3 ((W-w+1)*(H-h+1)), but it seems to be only 1 by 3 (look at code).
What is my mistake?
Here's the code:
int i, j;
IppiSize srcROI;
srcROI.width = 5;
srcROI.height = 5;
IppiSize tplROI;
tplROI.width = 3;
tplROI.height = 3;
Ipp8u testpic[] = {
128, 0, 0, 0, 128,
0, 128, 0, 128, 0,
0, 0, 128, 0, 0,
0, 128, 0, 128, 0,
128, 0, 0, 0, 128 };
Ipp8u testtpl[] = {
128, 0, 128,
0, 128, 0,
128, 0, 128};
// i thought the result should be a 3 by 3 image with
// largest value in the mid
int resStep;
int resSize = 5-3+1;
Ipp32f * res = ippiMalloc_32f_C1(resSize,resSize,&resStep);
int bufSize;
int mpicstep, mtplstep;
Ipp8u * mtestpic, *mtesttpl;
mtestpic = ippiMalloc_8u_C1(5,5,&mpicstep);
mtesttpl = ippiMalloc_8u_C1(3,3,&mtplstep);
for(j=0; j5; j++)
for(i=0; i5; i++) mtestpic[i+j*mpicstep] = testpic[i+j*5];
for(j=0; j3; j++)
for(i=0; i3; i++) mtesttpl[i+j*mtplstep] = testtpl[i+j*3];
for(j=0; j3; j++)
for(i=0; i3; i++) res[i+j*resStep] = 3.3f;
ippiMatchTemplateGetBufSize_CorrNormed(
srcROI, tplROI, ipp8u, &bufSize);
Ipp8u* buffer = ippsMalloc_8u(bufSize);
switch(
ippiMatchTemplate_CorrNormed_8u32f_C1R(
mtestpic, mpicstep, srcROI,
mtesttpl, mtplstep, tplROI,
res, resStep, buffer)
)
{
case ippStsNullPtrErr: printf("ippStsNullPtrErr "); break;
case ippStsSizeErr: printf("ippStsSizeErr "); break;
case ippStsStepErr: printf("ippStsStepErr "); break;
case ippStsNotEvenStepErr: printf("ippStsNotEvenStepErr "); break;
case ippStsNoErr: printf("OK ");
}
printf(" Match-Result: ");
for(j=0; j
{
for(i=0; i
{
printf("%1.3g ", res[i+j*resStep]);
}
printf(" ");
}
ippiFree(mtestpic);
ippiFree(mtesttpl);
ippiFree(res);
ippsFree(buffer);
Thanks in advance,
J. Blaser
i'm quite new to the IPP and tried to write a little
program for testing ippiMatchTemplate, but the output of
the program is not what i expected. I think it has
to be 3 by 3 ((W-w+1)*(H-h+1)), but it seems to be only 1 by 3 (look at code).
What is my mistake?
Here's the code:
int i, j;
IppiSize srcROI;
srcROI.width = 5;
srcROI.height = 5;
IppiSize tplROI;
tplROI.width = 3;
tplROI.height = 3;
Ipp8u testpic[] = {
128, 0, 0, 0, 128,
0, 128, 0, 128, 0,
0, 0, 128, 0, 0,
0, 128, 0, 128, 0,
128, 0, 0, 0, 128 };
Ipp8u testtpl[] = {
128, 0, 128,
0, 128, 0,
128, 0, 128};
// i thought the result should be a 3 by 3 image with
// largest value in the mid
int resStep;
int resSize = 5-3+1;
Ipp32f * res = ippiMalloc_32f_C1(resSize,resSize,&resStep);
int bufSize;
int mpicstep, mtplstep;
Ipp8u * mtestpic, *mtesttpl;
mtestpic = ippiMalloc_8u_C1(5,5,&mpicstep);
mtesttpl = ippiMalloc_8u_C1(3,3,&mtplstep);
for(j=0; j5; j++)
for(i=0; i5; i++) mtestpic[i+j*mpicstep] = testpic[i+j*5];
for(j=0; j3; j++)
for(i=0; i3; i++) mtesttpl[i+j*mtplstep] = testtpl[i+j*3];
for(j=0; j3; j++)
for(i=0; i3; i++) res[i+j*resStep] = 3.3f;
ippiMatchTemplateGetBufSize_CorrNormed(
srcROI, tplROI, ipp8u, &bufSize);
Ipp8u* buffer = ippsMalloc_8u(bufSize);
switch(
ippiMatchTemplate_CorrNormed_8u32f_C1R(
mtestpic, mpicstep, srcROI,
mtesttpl, mtplstep, tplROI,
res, resStep, buffer)
)
{
case ippStsNullPtrErr: printf("ippStsNullPtrErr "); break;
case ippStsSizeErr: printf("ippStsSizeErr "); break;
case ippStsStepErr: printf("ippStsStepErr "); break;
case ippStsNotEvenStepErr: printf("ippStsNotEvenStepErr "); break;
case ippStsNoErr: printf("OK ");
}
printf(" Match-Result: ");
for(j=0; j
{
for(i=0; i
{
printf("%1.3g ", res[i+j*resStep]);
}
printf(" ");
}
ippiFree(mtestpic);
ippiFree(mtesttpl);
ippiFree(res);
ippsFree(buffer);
Thanks in advance,
J. Blaser
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great, for your convenience, using MathTemplate function discussed here several times, so probably you can find it useful to read related topics:
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi!
none of the links works
could you tell me, please, what whould be the correct output in this example in case it woul de corrected (the error with indexes, i mean)
should the output matrix be symmentic?
regards,
Petr
none of the links works
could you tell me, please, what whould be the correct output in this example in case it woul de corrected (the error with indexes, i mean)
should the output matrix be symmentic?
regards,
Petr
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page