Function File: im2uint16 (img)
Function File: im2uint16 (img, "indexed")

Convert image to uint16.

The conversion of img to a 16-bit unsigned integer, is dependent on the type of input image. The following input classes are supported for non-indexed images:

int16 or uint8

Values are rescaled to the range of the uint16 class [0 65535].

logical

True and false values are assigned a value of 0 and 255 respectively.

double or single

Values are truncated to the interval [0 1] and then rescaled to the range of values of the int16 class [0 255].

uint16

Returns the same image.

If the second argument is the string "indexed", then values are cast to uint16, and a -1 offset is applied if input is a floating point class. Input checking is performed and an error will be throw is the range of values in uint16 is not enough for all the image indices.

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

Package: image