function mmdataconv % MMDATACONV Data type conversion % % MMDATACONV % % In the previous versions of MATLAB, the only data type supported % was DOUBLE. From version 5, the formats uint8, logical uint8 and % uint16 are also supported. The logical uint8 represents just the % numbers 0 and 1, the uint8 represents positive integers from 0 to % 255, and the uint16 represents positive integers from 0 to 65535. % The SDC Morphology Toolbox uses just these 3 new data types. % % The SDC Morphology Toolbox supports binary and gray-scale images % ( or signals) . The binary images (or signals) are represented % in the logical uint8 data type, while the gray-scale images (or % signals) are represented in the uint8 and uint16 data types. Note % that any image (or signal) represented in logical uint8 may be % represented in uint8 or uint16 and that any image (or signal) in % uint8 may be represented in uint16. % % If an image (or signal) is not in the required data type, than it % should be converted to the maximum and nearest SDC Morphology % Toolbox data type. For example, if an image (or signal) is in % DOUBLE and a morphological gray-scale processing is required, it % should be converted to uint16. Another example, if a uint8 % logical image (or signal) should be added to a uint8 image (or % signal), the logical uint8 image (or signal) should be converted % to uint8. % % In cases of operators that have as parameters an image (or signal) % and a constant, the type of the image (or signal) should be kept % as reference, while the type of the constant should be converted, % if necessary. % % There are two cases that should be considered: conversion to a % binary and to a gray-scale image (or signal). In the first case, % 0 should be kept and values different of 0 should be converted to % 1, while in the second one, it is necessary casting to uint8 or % uint16. % % The SDC Morphology Toolbox has the possibility of automatic data % type conversion. The function MMFREEDOM controls the 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. % % Examples % -------- % % a=mmneg([0 1 2]) % whos('a') % % % % % EXPLANATION: [0 1 2] is a double image and MMNEG requires a gray- % scale or binary image. The nearest image type supported by the % toolbox is the gray-scale uint16. The double image [0 1 2] is then % automatically converted to uint16[(0 1 2)]. % % % a=mmneg(logical([0 1 2])) % whos('a') % % % % EXPLANATION: logical([0 1 2]) is a binary image in the double % format. The nearest image type supported by the toolbox is binary % ( logical uint8). The converted binary image will be logical(uint8 % ( [0 1 1]) and the result of MMNEG is the negation of that. % % % a=mmsubm([4 2 1],uint8([3 2 0])) % whos('a') % % % % EXPLANATION: 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 uint16. Both are converted to uint16 and then % subtracted. The result is in uint16 type. % % % a=mmsubm([4 2 1], logical([3 2 0])) % whos('a') % % % % EXPLANATION:The first image is gray-scale double and the second is % binary double. The nearest image type supported by the toolbox is % gray-scale uint16. The second image is binary and when converted to % gray-scale uint16 will become uint16([1 1 0]). % % % a=mmsubm(uint8([4 3 2 1]), 1) % whos('a') % % % % EXPLANATION: Although the image is uint8 and the constant is double % the predominant type is given for the image and the double constant % will be converted to uint8. % % % a=mmsubm(2, logical([0 1 2 3])) % whos('a') % % % % EXPLANATION:The predominant type is binary (logical uint8). The % image will be converted to logical(uint8([0 1 1 1]) and the % constant will be converted to logical(uint8(1)) before the % application of the operator MMSUBM. % % See also MMCONV, MMFREEDOM. % begin of the default argument automatic treatment% end of the default argument automatic treatment 1 help mmdataconv % Copyright (c) 1998-2001 by SDC Information Systems.