| [mmbinary] [Up] [mmgray] | Data Type Conversion |
| User Feedback |
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 SDC Morphology Toolbox for MATLAB datatype. For example, if an image is in DOUBLE 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.
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 image from double to int32
Warning: converting image from uint8 to int32
a =
1 0 1
mmdatatype(a)
ans = 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 image from double to int32
Warning: converting image from double to int32
Warning: converting image from binary uint8 to int32
a =
3 1 1
mmdatatype(a)
ans = int32
Although the image is uint8 and the constant is double 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 image from scalar to uint8
a =
3 2 1 0
mmdatatype(a)
ans = uint8
| mmIMAGE | Toolbox image type |
| [mmbinary] [Up] [mmgray] | |
| User Feedback | |
| Copyright (c) 1998-2008 by SDC Information Systems |