| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
jimage = im2java(I)
jimage = im2java(X,MAP)
jimage = im2java(RGB)
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, java.awt.Image.
jimage = im2java(I) converts the intensity image I to an instance of the Java image class, java.awt.Image.
jimage = im2java(X,MAP) converts the indexed image X, with colormap MAP, to an instance of the Java image class, java.awt.Image.
jimage = im2java(RGB) converts the RGB image RGB to an instance of the Java image class, java.awt.Image.
The input image can be of class uint8, uint16, or double.
Note Java requires uint8 data to create an instance of the Java image class, java.awt.Image. If the input image is of class uint8, jimage contains the same uint8 data. If the input image is of class double or uint16, 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, java.awt.Image. |
This example reads an image into the MATLAB workspace and then uses im2java to convert it into an instance of the Java image class.
I = imread('ngc6543a.jpg');
javaImage = im2java(I);
frame = javax.swing.JFrame;
icon = javax.swing.ImageIcon(javaImage);
label = javax.swing.JLabel(icon);
frame.getContentPane.add(label);
frame.pack
frame.show

Bit-Mapped Images for related functions
![]() | im2frame | imag | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |