docs/examples/MultipleROI.java
/**
     * Function to plot data
     *
     * @param multiTag tag
     */
Function to plot data
@param multiTag tag
Function to plot data @param multiTag tag
private static void plotData(MultiTag multiTag) {
        DataArray dataArray = multiTag.getReferences().get(0);
        byte[] img_data = new byte[(int) dataArray.getDataExtent().getElementsProduct()];
        dataArray.getData(img_data, dataArray.getDataExtent(), new NDSize());
        DataArray position = multiTag.getPositions();
        DataArray extent = multiTag.getExtents();
        double[] position_data = new double[(int) position.getDataExtent().getElementsProduct()];
        position.getData(position_data, position.getDataExtent(), new NDSize());
        double[] extent_data = new double[(int) extent.getDataExtent().getElementsProduct()];
        extent.getData(extent_data, extent.getDataExtent(), new NDSize());
        try {
            BufferedImage img = ImageIO.read(new ByteArrayInputStream(img_data));
            int size = position_data.length;
            for (int i = 0; i < size; i += 3) {
                double[] pos = {position_data[i], position_data[i + 1], position_data[i + 2]};
                double[] ext = {extent_data[i], extent_data[i + 1], extent_data[i + 2]};
                drawRect(img, pos, ext);
            }
            ImageIO.write(img, "png", new java.io.File("multiple_roi_output.png"));
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
private static void plotData ( MultiTag multiTag ) { DataArray dataArray = multiTag . getReferences ( ) . get ( 0 ) ; byte [ ] img_data = new byte [ ( int ) dataArray . getDataExtent ( ) . getElementsProduct ( ) ] ; dataArray . getData ( img_data , dataArray . getDataExtent ( ) , new NDSize ( ) ) ; DataArray position = multiTag . getPositions ( ) ; DataArray extent = multiTag . getExtents ( ) ; double [ ] position_data = new double [ ( int ) position . getDataExtent ( ) . getElementsProduct ( ) ] ; position . getData ( position_data , position . getDataExtent ( ) , new NDSize ( ) ) ; double [ ] extent_data = new double [ ( int ) extent . getDataExtent ( ) . getElementsProduct ( ) ] ; extent . getData ( extent_data , extent . getDataExtent ( ) , new NDSize ( ) ) ; try { BufferedImage img = ImageIO . read ( new ByteArrayInputStream ( img_data ) ) ; int size = position_data . length ; for ( int i = 0 ; i < size ; i += 3 ) { double [ ] pos = { position_data [ i ] , position_data [ i + 1 ] , position_data [ i + 2 ] } ; double [ ] ext = { extent_data [ i ] , extent_data [ i + 1 ] , extent_data [ i + 2 ] } ; drawRect ( img , pos , ext ) ; } ImageIO . write ( img , "png" , new java . io . File ( "multiple_roi_output.png" ) ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } }
Function to plot data
 @param multiTag tag
Function to plot data @param multiTag tag
// get data array // retrieve image data as bytes // get position and extent data array // get position data // get extents data // create image // draw rectangles // write image to file