Documentation

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.

im2java2d

Convert image to Java buffered image

Syntax

jimage = im2java2d(I)
jimage = im2java2d(X,MAP)

Description

jimage = im2java2d(I) converts the image I to an instance of the Java image class java.awt.image.BufferedImage. The image I can be an intensity (grayscale), RGB, or binary image.

jimage = im2java2d(X,MAP) converts the indexed image X with colormap MAP to an instance of the Java class java.awt.image.BufferedImage.

    Note   The im2java2d function works with the Java 2D API. The im2java function works with the Java Abstract Windowing Toolkit (AWT).

Class Support

Intensity, indexed, and RGB input images can be of class uint8, uint16, or double. Binary input images must be of class logical.

Examples

Read an image into the MATLAB® workspace and then use im2java2d to convert it into an instance of the Java class java.awt.image.BufferedImage.

I = imread('moon.tif');
javaImage = im2java2d(I);
frame = javax.swing.JFrame;
icon = javax.swing.ImageIcon(javaImage);
label = javax.swing.JLabel(icon);
frame.getContentPane.add(label);
frame.pack
frame.show

Introduced before R2006a

Was this topic helpful?