Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
6654 Discussions

GradientVectorSobel doesn't work for signed Ipp16s Source Images

Simon_77
Beginner
416 Views

When calling ippiGradientVectorSobel_16s32f_C1R the source image values are seemingly interpreted as unsigned values instead of being interpreted as signed values.

What did I do? I tried to use ippiGradientVectorSobel to compute the 2nd partial derivatives. First I applied ippiGradientVectorPrewitt_8u16s_C1R on the source image to get two 16-bit images, containing the signed gradient in x- and in y-direction. Afterwards I applied ippiGradientVectorSobel_16s32f_C1R on the resulting signed 16 bit images, expecting the four resulting images to contain the 2nd partial derivatives as signed float values.

Unfortunately, there seems to be some confusion with the sign of the input values. Example:

The 16 bit source image passed to ippiGradientVectorSobel_16s32f_C1R contains at a location the following values:

|15  5  -3|

|20  6  -4|

|20  7  -4|

The Sobel operator should compute 15 + 2 * 20 + 20 -(-3) -(-4) -(-4) = 90. However, the result computed by ippiGradientVectorSobel_16s32f_C1R is -262054. This would be the result, if the negative values were interpreted as unsigned short values (replace -3 by (2^16) - 3 =  65533 and -4 by (2^16) - 4 = 65532):

15 + 2 * 20 + 20 - 65533 - 2 * 65532 - 65532 = -262054

At places where only positives values are within the mask, the result is as expected correct.

0 Kudos
6 Replies
ShanmukhS_Intel
Moderator
404 Views

Hi,

 

Thank you for posting on Intel Communities.

 

Could you please share us a IPP version, sample reproducer and steps(if any), so that we could try reproducing the issue at our end.

 

Best Regards,

Shanmukh.SS

 

ShanmukhS_Intel
Moderator
379 Views

Hi,


A gentle reminder:

Could you please share us a IPP version, sample reproducer and steps(if any), so that we could try reproducing the issue at our end.


Best Regards,

Shanmukh.SS


Simon_77
Beginner
371 Views

I've tried to write a minimal reproducer, but the problem did no longer occur with it. When passing a large image to the function, however, the bug persists.

Anyway, I've got an idea, where the problem might lie: the memory of the image I had passed was not necessarily 64-byte aligned, which is required for at leat some IPP functions as I read. I will try to enforce a 64-byte alignment and check, if the problems still occurs.

The used version is still 2018.0.3. We will update to the current version of IPP on one of the next days.

ShanmukhS_Intel
Moderator
344 Views

Hi,


>>I will try to enforce a 64-byte alignment and check, if the problems still occurs.

Sure, Please let us know if issue persists with above check or kindly let us know if issue exists even after updating to the latest IPP version.


Best Regards,

Shanmukh.SS


Simon_77
Beginner
334 Views

Hello,

I found the reason for the wrong results. It was not causes by IPP. I accidentally branched into ippiGradientVectorSobel_16u32f_C1R instead of ippiGradientVectorSobel_16s32f_C1R. Order of operations, had to add a pair of brackets...

 

Sorry for the inconvenience.

 

ShanmukhS_Intel
Moderator
322 Views

Hi,


Glad to know that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Best Regards,

Shanmukh.SS


Reply