# mmfreedom
Control automatic data type conversion.

## Synopsis

Y = mmfreedom( L = 5 )

Implemented in Python.

### Input

L | Double level of FREEDOM: 0, 1 or 2. If the input parameter is omitted, the current level is returned. Default: `5`

### Output

Y | Double current FREEDOM level

## Description

mmfreedom controls the automatic data type conversion. There are 3 possible levels, called FREEDOM levels, for automatic conversion: 0 - image type conversion is not allowed; 1- image type conversion is allowed, but a warning is sent for each conversion; 2- image type conversion is allowed without warning. The FREEDOM levels are set or inquired by mmfreedom. If an image is not in the required datatype, than it should be converted to the maximum and nearest pymorph Morphology Toolbox datatype. For example, if an image is in int32 and a morphological gray-scale processing that accepts only binary, uint8 or uint16 images, is required, it will be converted to uint16. Another example, if a binary image should be added to a uint8 image, the binary image will be converted to uint8.
In cases of operators that have as parameters an image and a constant, the type of the image should be kept as reference, while the type of the constant should be converted, if necessary.

## Examples

In the following code, both images are gray-scale images, the first image is double and the second is uint8. The nearest image type supported by the toolbox is int32. Both images are converted to int32 and then subtracted. The result is in int32 datatype.

    >>> a=mmsubm([4., 2., 1.],uint8([3, 2, 0]))

    Warning: Converting input image from double to int32.
    Warning: Converting input image from uint8 to int32.

    >>> print a

    [1 0 1]

    >>> print mmdatatype(a)

    int32

The first image is gray-scale double and the second is binary double. The nearest image type supported by the toolbox is gray-scale int32. The second image is binary and when converted to gray-scale int32 will become int32([1 1 0]).

    >>> a=mmsubm([4., 2., 1], mmbinary([3, 2, 0]))

    Warning: Converting input image from double to int32.
    Warning: Converting input image from binary uint8 to int32.

    >>> print a

    [3 1 1]

    >>> print mmdatatype(a)

    int32

Although the image is uint8 and the constant is int32 the predominant type is given for the image and the constant will be converted to uint8.

    >>> a=mmsubm(uint8([4, 3, 2, 1]), 1)

    Warning: Converting input image from int32 to uint8.

    >>> print a

    [3 2 1 0]

    >>> print mmdatatype(a)

    uint8

## Source Code

    def mmfreedom(L=5):
        Y = -1
        return Y

## See also

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