You are here : matlabImage Processingim2single

im2single() - Image Processing

I2 = im2single(I) converts the intensity
image I to single, rescaling the data if necessary.
If the input image is of class single, the output
image is identical to it.RGB2 = im2single(RGB) converts the truecolor
image RGB to single, rescaling the data if necessary.I = im2single(BW) converts the binary image BW to
a single-precision intensity image.X2 = im2single(X,'indexed') converts the
indexed image X to single precision, offsetting
the data if necessary. gpuarrayB = im2single(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 support:
Yes.MATLAB Function Block support:
Yes.


Syntax

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


Example

Convert Array to Class SingleOpen This Example
This example shows how to convert an array of class uint8 into class single .
Create a numeric array of class uint8 .I = reshape(uint8(linspace(1,255,25)),[5 5])

I =

    1   54  107  160  213
   12   65  117  170  223
   22   75  128  181  234
   33   86  139  192  244
   43   96  149  202  255

Convert the array to class single .I2 = im2single(I)

I2 =

    0.0039    0.2118    0.4196    0.6275    0.8353
    0.0471    0.2549    0.4588    0.6667    0.8745
    0.0863    0.2941    0.5020    0.7098    0.9176
    0.1294    0.3373    0.5451    0.7529    0.9569
    0.1686    0.3765    0.5843    0.7922    1.0000

Convert Array to Class Single on GPUCreate an array of class uint8 on the
GPU by creating a gpuArray object.I = gpuArray(reshape(uint8(linspace(1,255,25)),[5 5]))
I =

    1   54  107  160  213
   12   65  117  170  223
   22   75  128  181  234
   33   86  139  192  244
   43   96  149  202  255Convert the array from class uint8 to
class single on the GPU. You can pass im2single a
gpuArray object.I2 = im2single(I)
I2 =

    0.0039    0.2118    0.4196    0.6275    0.8353
    0.0471    0.2549    0.4588    0.6667    0.8745
    0.0863    0.2941    0.5020    0.7098    0.9176
    0.1294    0.3373    0.5451    0.7529    0.9569
    0.1686    0.3765    0.5843    0.7922    1.0000


Output / Return Value


Limitations


Alternatives / See Also


Reference