Erode/Dilate in IPP 3.0

Erode/Dilate in IPP 3.0

Hi all,

this question concerns the behaviour of the dilate and erode functions in IPP 3.0. The following sample code is meant to perform an out-of-placedilation with a 5-neighbourhood:

const unsigned char mask[9] = {0, 1, 0, 1, 1, 1, 0, 1, 0};
IppiSize maskSize = {3, 3};
IppiPoint anchor = {1, 1};
int bs1, bs2;
Ipp8u *image1 = (Ipp8u *) ippiMalloc_8u_C1(672,486, &bs1); // bs1 is set to 672 as expected (divisible by 32)
Ipp8u *image2 = (Ipp8u *) ippiMalloc_8u_C1(672,486, &bs2); // same for bs2
IppiSize myroiSize = {672, 486};
istat = ippiDilate_8u_C1R(image1, bs1, image2, bs2, myroiSize, mask, maskSize, anchor);
ippiFree(image2);
ippiFree(image1);

This gives the return code istat: "Stride value is less than the row length". But the strides bs1 and bs2 are 672, and so is myroiSize.width. So what's wrong?

By decreasing the roi width to 670, ippiDilate can be called. When adding these lines just before the call to ippiDilate:

istat = ippiSet_8u_C1R(0, image1, bs1, myroiSize); // set image to black
myroiSize.width = 670; // 671 won't work either
image1[673] = 1; // set one non-zero element, at the (1,1) position in the image

This input data is generated in the lower left corner of image1, as expected:

0 0 0
0 1 0
0 0 0

But this is the corresponding 3x3 corner of image2:

11 1 0
1 1 1
0 1 0

Where does the 11 come from? How do the dilate/erode functions treat borders?

Thanks for your help,
Daniel

3 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

I think that the neighborhood processing is necessary for the function.
(Manual 9-3)

Mamual Example 8-1 Dilation of a Dot (Manual 8-6)

IppStatus dilate( void ) {
Ipp8u x[7*5];
IppiSize roi = {7,5};
ippiSet_8u_C1R( 0, x, 7, roi );
x[2*7+3] = 1;
roi.width = roi.width - 2;
roi.height = roi.height - 2;
return ippiDilate3x3_8u_C1IR( x+7+1, 7, roi );
}

Hi,

thanks for your mail. Works fine now.

Regards, Daniel

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui