12.07.2015 Views

MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

imageWhen you write an indexed image using imwrite, <strong>MATLAB</strong> automaticallyconverts the values if necessary.ColormapsColormaps in <strong>MATLAB</strong> are alway m-by-3 arrays of double-precisionfloating-point numbers in the range [0, 1]. In most graphics file formats,colormaps are stored as integers, but <strong>MATLAB</strong> does not support colormapswith integer values. imread and imwrite automatically convert colormapvalues when reading and writing files.True Color ImagesIn a truecolor image of class double, the data values are floating-pointnumbers in the range [0, 1]. In a truecolor image of class uint8, the data valuesare integers in the range [0, 255] and for truecolor image of class uint16 thedata values are integers in the range [0, 65535]If you want to convert a truecolor image from one data type to the other, youmust rescale the data. For example, this statement converts a uint8 truecolorimage to double,RGB64 = double(RGB8)/255;or for uint16 images,RGB64 = double(RGB16)/65535;This statement converts a double truecolor image to uint8.RGB8 = uint8(round(RGB64*255));or for uint16 images,RGB16 = uint16(round(RGB64*65535));The order of the operations must be as shown in these examples, because youcannot perform mathematical operations on uint8 or uint16 arrays.When you write a truecolor image using imwrite, <strong>MATLAB</strong> automaticallyconverts the values if necessary.ObjectHierarchy2-231

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!