LabKit MATLAB Workbench

reference

API ReferenceImage API

labkit.image.im2double

Convert image data to double using MATLAB's im2double contract.

Syntax

imageOut = labkit.image.im2double(imageIn) imageOut = labkit.image.im2double(indexedImage, "indexed")

Description

Converts image data to double without requiring Image Processing Toolbox. Logical values become 0 or 1. uint8 and uint16 values are divided by the maximum value of their class. int16 values are mapped linearly from the complete signed range to [0,1]. single and double values are converted to double without rescaling or clipping.

For uint8 or uint16 indexed images, the "indexed" form converts the zero-based integer storage to one-based double colormap indices. For example, uint8 values [0 1] become [1 2]. Empty input returns an empty double array.

Inputs

imageIn
Logical, uint8, uint16, int16, single, or double image array.
imageType
Optional character vector or scalar string "indexed". No other image-type value is accepted.

Outputs

imageOut
Double array with the same size as imageIn.

Errors

labkit:image:im2double:InvalidImageType
imageType is not "indexed".
labkit:image:im2double:UnsupportedClass
imageIn has an unsupported numeric class.

Example

intensity = labkit.image.im2double(uint8([0 128 255]));
indices = labkit.image.im2double(uint8([0 1 2]), "indexed");

Source

This page is generated from the MATLAB help text in +labkit/+image/im2double.m.