[mmToggle] [Up] [mmIntersec] Operations

mmAddm
Addition of two images, with saturation.

Synopsis

Image mmAddm ( const Image& f1 , const Image& f2 );

Input

f1 Image [ Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image ]

f2 Image [ Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image ]

Or constant.

Output

y Image [ Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image ]

Description

mmAddm creates the image y by pixelwise addition of images f1 and f2. When the addition of the values of two pixels saturates the image data type considered, the greatest value of this type is taken as the result of the addition.

Examples

unsigned char _f[] = {255, 255,  0,  10,   0, 255, 250};
unsigned char _g[] = {  0,  40, 80, 140, 250,  10,  30};
Image f  = Image(7, 1, 1, "uint8", (char *)_f);
Image g  = Image(7, 1, 1, "uint8", (char *)_g);
Image y1 = mmAddm(f, g); 
Image y2 = mmAddm(g, 100);
printf("y1 =\n%s\n", (char *)y1.str());
printf("y2 =\n%s\n", (char *)y2.str());

y1 =
    255 255  80 150 250 255 255 
y2 =
    100 140 180 240 255 110 130

Image a = mmReadgray("keyb.tif");
Image b = mmAddm(a, 128);
mmShow(a);
mmShow(b);

a b

Equation

See also

mmSubm Subtraction of two images, with saturation.
mmLimits Get the possible minimum and maximum of an image.
[mmToggle] [Up] [mmIntersec]