im2java

Convert image to Java image

Description

To work with a MATLAB® image in the Java® environment, you must convert the image from its MATLAB representation into an instance of the Java image class, sun.awt.image.ToolkitImage.

jimage = im2java(RGB) converts the truecolor (RGB) image RGB to an instance of the Java image class.

jimage = im2java(I) converts the grayscale (intensity) image I to an instance of the Java image class.

jimage = im2java(X,map) converts the indexed image X, with colormap map, to an instance of the Java image class.

Input Arguments

collapse all

RGB image, specified as an m-by-n-by-3 numeric array. If you specify an image of data type double, then values must be in the range [0, 1].

Data Types: double | uint8 | uint16

Grayscale image, specified as an m-by-n numeric matrix. If you specify an image of data type double, then values must be in the range [0, 1].

Data Types: double | uint8 | uint16

Indexed image, specified as an m-by-n matrix of nonnegative integers.

  • If you specify X as an array of data type uint8 or uint16, then values must be in the range [0, c-1].

  • If you specify X as an array of data type double, then values must be in the range [1, c].

Data Types: double | uint8 | uint16

Colormap associated with indexed image X, specified as a c-by-3 matrix with values in the range [0, 1]. Each row of map is a three-element RGB triplet that specifies the red, green, and blue components of a single color of the colormap. The colormap can have a maximum of 256 colors.

Data Types: double

Output Arguments

collapse all

Java image, returned as a sun.awt.image.ToolkitImage.

Tips

  • Java requires uint8 data to create an instance of the Java image class, sun.awt.image.ToolkitImage. If the input image is of class double or uint16, then im2java makes an equivalent image of class uint8, rescaling or offsetting the data as necessary, and then converts this uint8 representation to an instance of the Java image class. For more information, see 8-Bit and 16-Bit Images.

See Also

Introduced before R2006a