Convert image to double precision
I2 = im2double(I) converts the intensity image I to double precision, rescaling the data if necessary. I can be a grayscale intensity image, a truecolor image, or a binary image.
If the input image is of class double, then the output image is identical.
I2 = im2double(I,'indexed') converts the indexed image I to double precision, offsetting the data if necessary.
I = imread('peppers.png'); whos I
Name Size Bytes Class Attributes I 384x512x3 589824 uint8
I2 = im2double(I); whos I2
Name Size Bytes Class Attributes I2 384x512x3 4718592 double
Convert an array to class double on the GPU. This example requires the Parallel Computing Toolbox™.
I1 = gpuArray(reshape(uint8(linspace(1,255,25)),[5 5])); I2 = im2double(I1);
Input image, specified as a scalar, vector, matrix, or multidimensional array.
If I is an intensity or truecolor image, it can be uint8, uint16, double, logical, single, or int16.
If I is an indexed image, it can be uint8, uint16, double or logical.
If I is a binary image, it must be logical.
If the Parallel Computing Toolbox is installed, I can be a gpuArray and im2double converts I on a GPU.
Data Types: single | double | int16 | uint8 | uint16 | logical