主要内容

渲染MATLAB图像数据在Java

本节包含一些代码片段,用于演示与使用图形和图像数据相关的特定功能。

处理图像

从组件中的图像中获取编码图像字节

public byte[] getByteArrayFromDeployedComponent() {Object[] byteImageOutput = null;MWNumericArray numericImageByteArray = null;try {byteImageOutput =部署。getImageDataOrientation(1, //Number Of Outputs 500, //Height 500, //Width 30, //Elevation 30, //Rotation "png" //图像格式);numericImageByteArray = (MWNumericArray) byteImageOutput [0];返回numericImageByteArray.getByteData ();} finally {MWArray.disposeArray(byteImageOutput);}}

在组件中获取缓冲图像

public byte[] getByteArrayFromDeployedComponent() {Object[] byteImageOutput = null;MWNumericArray numericImageByteArray = null;try {byteImageOutput =部署。getImageDataOrientation(1, //Number Of Outputs 500, //Height 500, //Width 30, //Elevation 30, //Rotation "png" //图像格式);numericImageByteArray = (MWNumericArray) byteImageOutput [0];返回numericImageByteArray.getByteData ();} finally {MWArray.disposeArray(byteImageOutput);}} public BufferedImage getBufferedImageFromDeployedComponent() {try {byte[] imageByteArray = getByteArrayFromDeployedComponent()返回ImageIO。读(新ByteArrayInputStream (imageByteArray));} catch(IOException io_ex) {io_ex. printstacktrace ();}}

创建缓冲图像MATLAB数组

使用renderArrayData方法:

  • 在给定的MATLAB中创建一个缓冲图像®数组中。

  • 验证阵列是三维的(高度、宽度和颜色组件)。

  • 验证颜色组件顺序为红色、绿色和蓝色。

    看到renderArrayData在Java®有关输入参数、返回值、抛出的异常和示例的API文档。