docs/examples/SingleROI.java
/**
     * Function to plot data
     *
     * @param tag tag
     */
Function to plot data
@param tag tag
Function to plot data @param tag tag
private static void plotData(Tag tag) {
        DataArray dataArray = tag.getReferences().get(0);
        byte[] img_data = new byte[(int) dataArray.getDataExtent().getElementsProduct()];
        dataArray.getData(img_data, dataArray.getDataExtent(), new NDSize());
        double[] pos = tag.getPosition();
        double[] ext = tag.getExtent();
        try {
            BufferedImage img = ImageIO.read(new ByteArrayInputStream(img_data));
            drawRect(img, pos, ext);
            ImageIO.write(img, "png", new java.io.File("single_roi_output.png"));
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
private static void plotData ( Tag tag ) { DataArray dataArray = tag . getReferences ( ) . get ( 0 ) ; byte [ ] img_data = new byte [ ( int ) dataArray . getDataExtent ( ) . getElementsProduct ( ) ] ; dataArray . getData ( img_data , dataArray . getDataExtent ( ) , new NDSize ( ) ) ; double [ ] pos = tag . getPosition ( ) ; double [ ] ext = tag . getExtent ( ) ; try { BufferedImage img = ImageIO . read ( new ByteArrayInputStream ( img_data ) ) ; drawRect ( img , pos , ext ) ; ImageIO . write ( img , "png" , new java . io . File ( "single_roi_output.png" ) ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } }
Function to plot data
 @param tag tag
Function to plot data @param tag tag
// get data array // retrieve image data as bytes // retrieve position and extents arrays // create image // draw rectangle // write image to file