| [mmtoggle] [Up] [mmintersec] | Operations |
Implemented in Python.
| y | Image Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image. |
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.
>>> f = uint8([255, 255, 0, 10, 0, 255, 250])
>>> g = uint8([ 0, 40, 80, 140, 250, 10, 30])
>>> y1 = mmaddm(f,g)
>>> print y1
[255 255 80 150 250 255 255]
>>> y2 = mmaddm(g, 100)
Warning: Converting input image from int32 to uint8.
>>> print y2
[100 140 180 240 255 110 130]
def mmaddm(f1, f2):
from Numeric import array, minimum, maximum
if type(f2) is array:
assert f1.typecode() == f2.typecode(), 'Cannot have different datatypes:'
y = maximum(minimum(f1.astype('d')+f2, mmlimits(f1)[1]),mmlimits(f1)[0])
y = y.astype(f1.typecode())
return y
| [mmtoggle] [Up] [mmintersec] | |
| Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center. |