Documentation Center

  • Trial Software
  • Product Updates

im2double

Convert image to double precision

Syntax

I2 = im2double(I)
RGB2 = im2double(RGB)
I = im2double(BW)
X2 = im2double(X,'indexed')
gpuarrayB = im2double(gpuarrayA,___)

Description

I2 = im2double(I) converts the intensity image I to double precision, rescaling the data if necessary.

If the input image is of class double, the output image is identical.

RGB2 = im2double(RGB) converts the truecolor image RGB to double precision, rescaling the data if necessary.

I = im2double(BW) converts the binary image BW to a double-precision intensity image.

X2 = im2double(X,'indexed') converts the indexed image X to double precision, offsetting the data if necessary.

gpuarrayB = im2double(gpuarrayA,___) performs the conversion on a GPU. The input image and the output image are gpuArrays. This syntax requires the Parallel Computing Toolbox™.

Code Generation

im2double supports the generation of efficient, production-quality C/C++ code from MATLAB. To see a complete list of toolbox functions that support code generation, see List of Supported Functions with Usage Notes.

Class Support

Intensity and truecolor images can be uint8, uint16, double, logical, single, or int16. Indexed images can be uint8, uint16, double or logical. Binary input images must be logical. The output image is double.

If the input gpuArray gpuarrayA is an intensity or truecolor image, it can be uint8, uint16, double, logical, single, or int16. If gpuarrayA is an indexed image, it can be uint8, uint16, double or logical. If gpuarrayA is a binary image, it must be logical. The output gpuArray image is double.

Examples

Convert array to class double.

I1 = reshape(uint8(linspace(1,255,25)),[5 5])
I2 = im2double(I1)

Convert array to class double on the GPU.

I1 = gpuArray(reshape(uint8(linspace(1,255,25)),[5 5]))
I2 = im2double(I1)

See Also

| | | | |

Was this topic helpful?