Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® Integrated Performance Primitives
- Compare with result 1 or 0

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Marcus_Hennecke

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-12-2011
08:44 AM

100 Views

Compare with result 1 or 0

I would like to count the number of pixels in a neighborhood for which a certain condition is true.

The idea is that I use ippiCompare to find those pixels for which the condition is true and then use ippiSumWindowRow and ippiSumWindowColumn to basically add all the pixels that are not zero.

In Matlab this is easy as the compare operation delivers a 1 for the true condition. A filter with a box kernel then does the trick. As the kernel is 11x11 in size, it can never overflow even uint8 images. However in the ippi library the compare operation delivers a result of 255 for the true conditions. I would first have to shift the pixels by seven bits to the right to get ones.

Alternatively, I could misuse the Threshold_LTValGTVal function to ensure that I only get zeros and ones.

Is there a better and more efficient way?

Best regards,

Marcus

Link Copied

4 Replies

SergeyKostrov

Valued Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-12-2011
08:55 PM

100 Views

You're comparing withsome value, right? A threshold, for example.

>>...However in the ippi library the compare operation delivers a result of 255 for the true conditions...

All

equal to

Could you post a Test-Case that reproduces the problem?

Best regards,

Sergey

Marcus_Hennecke

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-12-2011
11:26 PM

100 Views

thanks for your quick reply. However, I think you misunderstood my question.

The ippiCompare functions do a pixel-by-pixel compare of the source image with a threshold or with another image. The result of this compare is a destination image where the pixels of that image are set to 0 if the compare is false or 255 if the compare is true. What I need however is for those pixels where the comparison is true to be 1.

This isn't a bug, the library works as specified. However, I need to know for each pixel in the image, for how many pixels in its neighborhood the condition is true. If those pixels where the condition is true were set to 1 I only needed to do a simple filtering operation.

Best regards,

Marcus

igorastakhov

New Contributor II

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-15-2011
07:55 AM

100 Views

ippiFilterBox_8u will not overflow for all pixels=255 as it performs intermediate calculations in 32s (running sum algorithm is used) and then performsnormalization on thekernel size - so output is divided by 121 in your case.

Regards,

Igor

Marcus_Hennecke

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-19-2011
11:13 AM

100 Views

yes, it might be possible to use ippiFilterBox. The result of ippiCompare is 255 where it is true and thus, the result of ippiFilterBox will be the number of pixels times 255 divided by the area of the kernel, which is 121 in my case. Thus, to get the real number I would have to multiply with 121 and divide by 255.

As it turns out, I can move around some of the later computations such that I can avoid having to actually perform that multiply and divide.

Thanks for your help!

Best regards,

Marcus

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.