imagesc
just calls image
underneath. As for image
, it behaves a bit differently if integers or floats are supplied, as can be learned from image
's documentation:
If C
is of type double, then an RGB triplet value of [0 0 0]
corresponds to black and [1 1 1]
corresponds to white.
If C
is an integer type, then the image uses the full range of data to determine the color. For example, if C
is of type uint8
, then [0 0 0]
corresponds to black and [255 255 255]
corresponds to white. If CData
is of type int8
, then [-128 -128 -128]
corresponds to black and [127 127 127]
corresponds to white.
...
Converting Between Data Types
To convert indexed image data from an integer type to type double
, add 1. For example, if X8
is indexed image data of type uint8
, convert it to type double
using:
X64 = double(X8) + 1;
To convert indexed image data from type double
to an integer type, subtract 1 and use round
to ensure that all the values are integers. For example, if X64
is indexed image data of type double
, convert it to uint8
using:
X8 = uint8(round(X64 - 1));
To convert true color image data from an integer type to type double
, rescale the data. For example, if RGB8
is true color image data of type uint8
, convert it to double using:
RGB64 = double(RGB8)/255;
To convert true color image data from type double
to an integer type, rescale the data and use round
to ensure that all the values are integers. For example, if RGB64
is image data of type double
, convert it to uint8
using:
RGB8 = uint8(round(RGB64*255));