This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Convert image to 16-bit unsigned integers


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


I2 = im2uint16(I) converts the intensity image I to uint16, rescaling the data if necessary. If the input image is of class uint16, the output image is identical to it.

RGB2 = im2uint16(RGB) converts the truecolor image RGB to uint16, rescaling the data if necessary.

I = im2uint16(BW) converts the binary image BW to a uint16 intensity image, changing 1-valued elements to 65535.

X2 = im2uint16(X,'indexed') converts the indexed image X to uint16, offsetting the data if necessary. If X is of class double, max(X(:)) must be 65536 or less.

gpuarrayB = im2uint16(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

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 uint16.

If the input gpuArray gpuarrayA is an intensity or truecolor image, it can be uint8, uint16, int16, logical, single, or double. 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 uint16.


Convert array to uint16.

I1 = reshape(linspace(0,1,20),[5 4])
I2 = im2uint16(I1)
I1 =

         0    0.2632    0.5263    0.7895
    0.0526    0.3158    0.5789    0.8421
    0.1053    0.3684    0.6316    0.8947
    0.1579    0.4211    0.6842    0.9474
    0.2105    0.4737    0.7368    1.0000

I2 =

      0  17246  34492  51738
   3449  20695  37941  55187
   6898  24144  41391  58637
  10348  27594  44840  62086
  13797  31043  48289  65535

Convert array to uint16 on a GPU.

I1 = gpuArray(reshape(linspace(0,1,20),[5 4]))
I2 = im2uint16(I1)

More About

collapse all

Code Generation

This function supports the generation of C code using MATLAB® Coder™. Note that if you choose the generic MATLAB Host Computer target platform, the function generates code that uses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, see Understanding Code Generation with Image Processing Toolbox.

MATLAB Function Block

You can use this function in the MATLAB Function Block in Simulink.

Introduced before R2006a

Was this topic helpful?