[mmintersec] [Up] [mmsymdif] | Operations |
Implemented in Python.
y | Image Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image. |
mmsubm creates the image
y
by pixelwise subtraction of the image
f2
from the image
f1
. When the subtraction of the values of two pixels is negative, 0 is taken as the result of the subtraction. When
f1
and
f2
are binary images,
y
represents the set subtraction of
f2
from
f1
.
>>> f = uint8([255, 255, 0, 10, 20, 10, 0, 255, 255])
>>> g = uint8([10, 20, 30, 40, 50, 40, 30, 20, 10])
>>> print mmsubm(f, g)
[245 235 0 0 0 0 0 235 245]
>>> print mmsubm(f, 100)
Warning: Converting input image from int32 to uint8. [155 155 0 0 0 0 0 155 155]
>>> print mmsubm(100, f)
Warning: Converting input image from uint8 to int32. [-155 -155 100 90 80 90 100 -155 -155]
def mmsubm(f1, f2): from Numeric import array, minimum, maximum if type(f2) is array: assert f1.typecode() == f2.typecode(), 'Cannot have different datatypes:' y = minimum(maximum(f1.astype('d')-f2, mmlimits(f1)[0]), mmlimits(f1)[1]) y = y.astype(f1.typecode()) return y
[mmintersec] [Up] [mmsymdif] | ![]() |
Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center. |