Function File: imcast (img, type)
Function File: imcast (img, type, "indexed")

Convert image to specific data type type.

Converts a valid image img into another class type. A valid image must be of class logical, uint8, uint16, int16, single, or double.

If the image is indexed, the last argument may be the string "indexed". An indexed image may not be of class int16, single, or logical (see isind for details).

Details on how the conversion is performed is class dependent, and can be seen on the help text of im2double, im2single, im2uint8, im2uint16, and im2int16. For the case of logical, conversion to logical is equivalent to simply casting img to logical data type. Conversion from logical, true elements are converted to 1 in the case of floating point, or the maximum value in the case of integer types.

See also: im2bw, im2uint8, im2double, im2int16, im2single, im2uint16.

Package: image