# mmunion
Union of images.

## Synopsis

y = mmunion( f1, f2, f3 = None, f4 = None, f5 = None )

Implemented in Python.

### Input

f1 | Image Gray-scale (uint8 or uint16) or binary image.
f2 | Image Gray-scale (uint8 or uint16) or binary image. Or constant
f3 | Image Gray-scale (uint8 or uint16) or binary image. Or constant. Default: `None`
f4 | Image Gray-scale (uint8 or uint16) or binary image. Or constant. Default: `None`
f5 | Image Gray-scale (uint8 or uint16) or binary image. Or constant. Default: `None`

### Output

y | Image

## Description

mmunion creates the image `y` by taking the pixelwise maximum between the images `f1, f2, f3, f4,` and `f5`. When `f1, f2, f3, f4,` and `f5` are binary images, `y` represents the union of them.

## Examples

Numerical example:

    >>> f=uint8([255, 255,  0,  10,   0, 255, 250])

    >>> print 'f=',f

    f= [255 255   0  10   0 255 250]

    >>> g=uint8([  0,  40, 80, 140, 250,  10,  30])

    >>> print 'g=',g

    g= [  0  40  80 140 250  10  30]

    >>> print mmunion(f, g)

    [255 255  80 140 250 255 250]

    >>> print mmunion(f, 255)

    Warning: Converting input image from int32 to uint8.
    [255 255 255 255 255 255 255]

Binary image

    >>> a = mmreadgray('form-ok.tif')

    >>> b = mmreadgray('form-1.tif')

    >>> c = mmunion(a,b)

    >>> mmshow(a)

    >>> mmshow(b)

    >>> mmshow(c)

a | b |

c |

Binary with gray-scale image:

    >>> d = mmreadgray('danaus.tif')

    >>> e = mmcmp(d,'<',80)

    >>> f = mmunion(d,mmgray(e))

    >>> mmshow(d)

    >>> mmshow(e)

    >>> mmshow(f)

d | e |

f |

Gray scale image:

    >>> g = mmreadgray('tplayer1.tif')

    >>> h = mmreadgray('tplayer2.tif')

    >>> i = mmreadgray('tplayer3.tif')

    >>> j = mmunion(g,h,i)

    >>> mmshow(g)

    >>> mmshow(h)

    >>> mmshow(i)

    >>> mmshow(j)

g | h | i |

j |

## Equation

union:
generalized union:

## Source Code

    def mmunion(f1, f2, f3=None, f4=None, f5=None):
        from Numeric import maximum
        y = maximum(f1,f2)
        if f3: y = maximum(y,f3)
        if f4: y = maximum(y,f4)
        if f5: y = maximum(y,f5)
        y = y.astype(f1.typecode())
        return y

## See also

mmfreedom | Control automatic data type conversion.
mmintersec | Intersection of images.

[`mmsymdif`] [Up] [`mmimg2se`] |
Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center.