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

ippiFilter and border

ensonic
Beginner
1,603 Views
I want to apply ippiFilter() to a full image. Therefore I added a border before using ippiCopyConstBorder().
I will pass this borderedImage to ippiFilter() as the source.
What I mis is how I tell ippiFilter() to offset the image processing by anchor.x and anchor.y.
According to the formula in ippiman.pdf on page 419 it does not.
0 Kudos
8 Replies
ensonic
Beginner
1,603 Views
I've done some trial and error. It seems to work when I do

offsetData=borderedData+(anchor.y*(bordered_width*3) + anchor.x*3)

and pass offsetData instead of borderedData to ippFilter(). Is it supposed to be done like this, or am I overseeing something?

Note: I am using the _8u_C3R family of functions.
0 Kudos
Vladimir_Dudnik
Employee
1,603 Views
Hi,
there is answer from our expert:
The start point for C3 filter is calculated according to the formula:

strtSrc = (Ipp8u*)pSrc - ( kHeight - anchor.y - 1 ) * srcStep - ( kWidth - anchor.x - 1 ) * 3;

so for users image (if he want to filter the whole image) strtSrc point should be upper left corner of the border and he should pass pSrc pointer to the function. A customer should remember that a kernel is flipped before applying to an image.

Fffffbbbbbbbbbb
fffffbbbbbbbbbb
ffAffiiiiiiiiii
fffffiiiiiiiiii
fffffiiiiiiiiii
bbiiiiiiiiiiiii
bbiiiiiiiiiiiii

Here is an example for 5x5 mask, C1 image and anchor in the center of the kernel:

f = filter mask
b = border
i = image
A = anchor point and it should point to which pSrc should point
F = upper left corner or strtSrc point, from which filtering begins.

Regards,
Vladimir

0 Kudos
cs1975
Beginner
1,603 Views
hi Valdimir,

Could you help what shall be step size, As I was ending up getting ippStsStepErr,
I have created example 5x5 image, and added padding of 1 col, 1 row on top, bottom, left, right, the new size of bodered image is 7x7

I have copied source contents to newly created bordered image. I have created new image with same 7x7 size.

I calculated src step
as
srcStep = 7 * sizeof(float);

if run
aStatus = ippiFilter_32f_C1R(anImage, srcDstStep,
anImage_out, srcDstStep,
roiSize, anAverageKernal_in,
akernelSize_in, anchor);
I end up in step error, I can describe the variable i am using

float anImage[49];
float anImage_out[49];

roiSize = { 7,7 }
IppiSize akernelSize_in = {3,3};
IppiPoint anchor = {1,1};

Could give clue about step calculation.

regards,
Chandra-
0 Kudos
Vladimir_Dudnik
Employee
1,603 Views

Hello Chandra,

please take a look on comment provided by our expert:

srcStep had been calculated right.

But the code must be like this:

float anImage[7*7];

float anImage_out [

5*5];

/* Output image is less then input image.

For 3x3 kernel size the output image is less by

1 col & 1 row on top, bottom, left and right.

5 = 7 1 - 1. */

IppiSize aKernelSize_in = { 3,3 };

IppiPoint anchor = {1,1};

IppiSize roi

DstSize = { 5, 5 };

/* roiSize must fit for

output image. */

int srcStep = 7 * sizeof(float);

int dstStep =

5 * sizeof(float);

float *pSrc;

#define nChannels 1

/* The using filter is for one-channels images. ippiFilter_32f_

C1R */

Prepare input image anImage.

Prepare kernel anAverageKernel_in

pSrc = (float *)( (unsigned char *)anImage + srcStep * (aKernelSize_in.height anchor.y 1 ) );

/* The source pointer is moved by 1 row down. */

pSrc += ( aKernelSize_in.width anchor.x 1 ) * nChannels;

/* The source pointer is moved by 1 col right. */

aStatus = ippiFilter_32f_C1R (

pSrc,

srcStep,

anImage_out,

dstStep,

roiDstSize,

anAverageKernel,

aKernelSize,

anchor);

.

srcStep is row length of source image by bytes.

dstStep is row length of destination image by bytes

Regards,
Vladimir

0 Kudos
cs1975
Beginner
1,603 Views
Hi Valdimir,

the filter started working, had same issue with ippiErode, i had modified the code as you suggested, thanks.

warm regards,
chandra-
0 Kudos
Vladimir_Dudnik
Employee
1,604 Views

Thanks,

please feel free to share your feeling about IPP functionality performance or any issues you've met with it. It might help other in using this software and might help us to improve the future versions.

Regards,
Vladimir

0 Kudos
joefang
Beginner
1,604 Views

Thanks,

please feel free to share your feeling about IPP functionality performance or any issues you've met with it. It might help other in using this software and might help us to improve the future versions.

Regards,
Vladimir


Hi Vladimir,

I have a similar problem to use ippiFilter_32f_C1R(). I am pretty sure I follow the way you suggest early email. The function works with proper return status and results. However, it crashs at the second time call (from upper level IDL). The function actually return properly but the application down. If I comments out this function, the application works fine. Please advise.

Thanks.

Joe

0 Kudos
Vladimir_Dudnik
Employee
1,604 Views

Ho Joe,

The issue in previous post was related to incorrect usage of the function. Could you please provide a code snippet to show how do you use the function and what are parameters passed by at run time?

Regards,
Vladimir
0 Kudos
Reply