Documentation

im2int16

Convert image to 16-bit signed integers

Syntax

J = im2int16(I)
gpuarrayJ = im2int16(gpuarrayI)

Description

example

J= im2int16(I)converts the grayscale, RGB, or binary imageItoint16, rescaling the data if necessary.

If the input image is of classint16, then the output image is identical to it. If the input image is of classlogical, thenim2int16changes false-valued elements to -32768 and true-valued elements to 32767.

example

gpuarrayJ= im2int16(gpuarrayI)performs the conversion on a GPU. This syntax requires the Parallel Computing Toolbox™.

Examples

collapse all

Create an array of classdouble.

I = reshape(linspace(0,1,20),[5 4])
I =5×40 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

Convert the array to classint16.

I2 = im2int16(I)
I2 =5x4 int16 matrix-32768 -15522 1724 18970 -29319 -12073 5173 22419 -25870 -8624 8623 25869 -22420 -5174 12072 29318 -18971 -1725 15521 32767

Create array of classdouble.

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

Convert array toint16.

I2 = im2int16(I1)

Input Arguments

collapse all

Intensity, RGB, or binary image, specified as a numeric matrix of any size and dimensionality.

Data Types:single|double|int16|uint8|uint16|logical

Image when run on a GPU, specified asgpuArraycontaining a numeric matrix of any size and dimensionality.

Output Arguments

collapse all

Image with classint16, returned as a numeric matrix with the same size and dimensionality asI.

Data Types:int16

Image with classint16when run on a GPU, returned asgpuArraycontaining a numeric matrix described byJ.

Extended Capabilities

Introduced before R2006a

Was this topic helpful?