Turn on suggestions

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

Showing results for

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

Peter_Hauge

Beginner

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

01-06-2010
01:42 AM

64 Views

Scaled subtraction

Is there a way to achieve a scaled subtraction of e.g. two BYTE images A and B so as to avoid saturation? The desired output would be Out := 128 + (A-B)/2. Normally, each pixel result would be coded like Out := (A+twos_complement(B))>>1. The same would be very nice for color images, but for a 3-channel BYTE color image the operation would be exactly the same. Of course, it would also be nice for 16- and 32-bit images.

What exactly does the 32-bit Complement function do? I do not understand the very short description in the help. Is it related to twos complement?

It does not seem straight-forward to obtain the scaled subtraction with the available scaled versions and the automatic saturation of the current arithmetic functions.

Any help will be appreciated.

Thanks, Peter.

Link Copied

2 Replies

PaulF_IntelCorp

Employee

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

01-06-2010
09:58 PM

64 Views

I'm not sure I understand the Complement function, either, I'm still coming up to speed on the ippi* functions. It appears to be a special function for JPEG2000 encode and decode operations.

It sounds like the ippsSubC* functions might work for you (especially the sfs variants). Might require a little extra effort, depending on how your image data is laid out, but I think it provides the basic functionality you are looking for.

Paul

Peter_Hauge

Beginner

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

01-07-2010
12:17 AM

64 Views

Quoting - Peter Hauge

Is there a way to achieve a scaled subtraction of e.g. two BYTE images A and B so as to avoid saturation? The desired output would be Out := 128 + (A-B)/2. Normally, each pixel result would be coded like Out := (A+twos_complement(B))>>1. The same would be very nice for color images, but for a 3-channel BYTE color image the operation would be exactly the same. Of course, it would also be nice for 16- and 32-bit images.

What exactly does the 32-bit Complement function do? I do not understand the very short description in the help. Is it related to twos complement?

It does not seem straight-forward to obtain the scaled subtraction with the available scaled versions and the automatic saturation of the current arithmetic functions.

Any help will be appreciated.

Thanks, Peter.

Hi Paul,

Thanks for the quick reply. If you are right about the Complement-function we need not consider that anymore :). I am afraid that SubC won't do. It appears that the ipps-functions are pretty much overlapping with the ippi-functions, so I will refer to those instead. ippiSubC is used when one argument is a constant soippiSub would be the one to use if bothargumetns are images.

The problem is that the twos-complement method is actually a two-step process: 1st invert all bits, 2nd add one. So on each pixel the operation is more precisely: Out = (A+invert(B)+1)>>1. As you can see, the result in the parentheses actually requires 9 bits and therefore must be evaluated in a single function call. Splitting up the problem in several function calls will cost a bit (literarily ;) ). It might be that I am simply asking too much, but it would be a very nice function to have.

Or maybe the only solution is to convert to 16 bits (16u), make a left-shift, perform a subtraction, right-shift, and convert back to 8u. But is seems to be an awfully lot of memory allocation and operations to achieve a non-saturated subtraction of two 8u-images.

if there is a shorter way to the goal, please let me know.

Best regards, Peter

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

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