Function iaaddm

namespace:morph
page:iaaddm

Synopse

Addition of two images, with saturation.

  • y = iaaddm(f1, f2)
    • y: Image
    • f1: Image
    • f2: Image Or constant.
01. from numpy import *
02. 
03. def iaaddm(f1, f2):
04.     from ialimits import ialimits
05. 
06.     if type(f2) is array:
07.         assert f1.dtype == f2.dtype, 'Cannot have different datatypes:'
08.     k1,k2 = ialimits(f1)
09.     y = clip(f1.astype(int64)+f2, k1, k2)
10.     y = y.astype(f1.dtype)
11.     return y

Description

iaaddm 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

Example 1

1. from ia870 import iaaddm
2. 
3. f = uint8([255,   255,    0,   10,    0,   255,   250])
4. g = uint8([ 0,    40,   80,   140,  250,    10,    30])
5. y1 = iaaddm(f,g)
6. print y1
7. y2 = iaaddm(g, 100)
8. print y2
[255 255  80 150 250 255 255]
[100 140 180 240 255 110 130]

Example 2

1. a = adreadgray('keyb.tif')
2. b = iaaddm(a,128)
3. adshow(a)
4. adshow(b)

Equation

See Also

  • ialimits - range interval of a image datatype