# Board index » cppbuilder » Working over an image

## Working over an image

2003-08-11 05:52:02 PM
cppbuilder69
Is it possible to change the tone of an image in this way:
for example i have an image, it is did by an array of 232 010 090, 002 255
200 and so on... that is RGB, i would reduce the G value of 10 for all pixel
(for all image) so to have: 232 000 090, 002 245 200 and so on...
How does it is possible?
What are the library that allow to handle the image in this way?

## Re:Working over an image

i will try it, tnx my friend

## Re:Working over an image

sorry can u explain me how just does this: #define CLIP(x) (x>255) ? 255 :
(x < 0) ? 0 : x

{smallsort}

## Re:Working over an image

On Tue, 12 Aug 2003 09:53:28 +0200, "b"
<borland.public.cppbuilder.vcl.components.using>wrote:
##### Quote
sorry can u explain me how just does this: #define CLIP(x) (x>255) ? 255 :
(x < 0) ? 0 : x

It's a so called "saturation arithmetic", because prevents a value to be
wrapped either over 255 or under 0, producing a invalid result value falling
into the valid range for a pixel's component (R, G or B) intensity.
For example, if we have a vale of 240 (decimal) for a pixel's red component,
and we want to add the 10% of intensity, i.e. 24 (decimal) we will obtain a
final value of 240 + 24 =>264, which doesn't fit naturally into a byte. A
standard ALU wraps the result calculating the 8 value:
11110000 (240)
+ 00011000 (24)
===================
(1)00001000 8
Eight it's a value darker than 240!
On the other hand, a ALU with saturation Arithmetic, guarantees that the
resulting value never cross the rails, i.e. the min and the max value allowed
for a byte, regardless the fact that the actual result would have generated a
value outgoing the aforesaid boundaries. This kind of ALU are typical of
Digital Signal Processing (DSP) systems.
In order to simulate such behavior, you need for a macro like CLIP.
Giuliano