Search in sources :

Example 6 with PlanarImage

use of javax.media.jai.PlanarImage in project vcell by virtualcell.

the class ROIMultiPaintManager method resizeXYUShort.

public static PlanarImage resizeXYUShort(short[] shortArr, int numX, int numY, Float scaleX, Float scaleY) {
    BufferedImage bufferedImage = new BufferedImage(numX, numY, BufferedImage.TYPE_USHORT_GRAY);
    short[] shortData = ((DataBufferUShort) bufferedImage.getRaster().getDataBuffer()).getData();
    System.arraycopy(shortArr, 0, shortData, 0, shortArr.length);
    PlanarImage planarImage = ScaleDescriptor.create(bufferedImage, scaleX, scaleY, 0f, 0f, new InterpolationNearest(), null);
    return planarImage;
// PaddedInfo paddedInfo = new PaddedInfo();
// paddedInfo.paddedArray = ((DataBufferUShort)planarImage.getData().getDataBuffer()).getData();
// paddedInfo.paddedISize = new ISize(planarImage.getWidth(), planarImage.getHeight(), 1);
// return paddedInfo;
}
Also used : InterpolationNearest(javax.media.jai.InterpolationNearest) DataBufferUShort(java.awt.image.DataBufferUShort) BufferedImage(java.awt.image.BufferedImage) PlanarImage(javax.media.jai.PlanarImage)

Example 7 with PlanarImage

use of javax.media.jai.PlanarImage in project vcell by virtualcell.

the class ROIMultiPaintManager method padXYByte.

public static byte[] padXYByte(byte[] byteArr, int numX, int numY, int left, int right, int top, int bottom) {
    BufferedImage bufferedImage = new BufferedImage(numX, numY, BufferedImage.TYPE_BYTE_GRAY);
    byte[] byteData = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
    System.arraycopy(byteArr, 0, byteData, 0, byteArr.length);
    PlanarImage planarImage = BorderDescriptor.create(bufferedImage, left, right, top, bottom, null, null).getRendering();
    return ((DataBufferByte) planarImage.getData().getDataBuffer()).getData();
}
Also used : DataBufferByte(java.awt.image.DataBufferByte) BufferedImage(java.awt.image.BufferedImage) PlanarImage(javax.media.jai.PlanarImage)

Example 8 with PlanarImage

use of javax.media.jai.PlanarImage in project vcell by virtualcell.

the class OverlayImageDisplayJAI method refreshImage.

public void refreshImage() {
    PlanarImage sourceOverlay = null;
    RenderedImage contrastEnhancedUnderlyingImage = createContrastEnhancedUnderlyingImage();
    if (underlyingImage != null && (highlightImage != null || allROICompositeImage != null)) {
        sourceOverlay = PlanarImage.wrapRenderedImage(computeComposite(contrastEnhancedUnderlyingImage));
    } else if (underlyingImage != null) {
        sourceOverlay = PlanarImage.wrapRenderedImage(contrastEnhancedUnderlyingImage);
    } else if (highlightImage != null && allROICompositeImage == null) {
        sourceOverlay = PlanarImage.wrapRenderedImage(highlightImage);
    } else if (allROICompositeImage != null && highlightImage == null) {
        sourceOverlay = PlanarImage.wrapRenderedImage(allROICompositeImage);
    } else if (allROICompositeImage != null && highlightImage != null) {
        sourceOverlay = CompositeDescriptor.create(highlightImage, allROICompositeImage, makeAlpha(allROICompositeImage.getWidth(), allROICompositeImage.getHeight(), (float) (100 - blendPercent) / (float) 10), makeAlpha(highlightImage.getWidth(), highlightImage.getHeight(), (float) (100 - blendPercent) / (float) 10), false, CompositeDescriptor.NO_DESTINATION_ALPHA, null);
    } else {
        sourceOverlay = PlanarImage.wrapRenderedImage(new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB));
    }
    if (sourceOverlay != null) {
        sourceOverlay = ScaleDescriptor.create(sourceOverlay, (float) zoom, (float) zoom, 0f, 0f, Interpolation.getInstance(Interpolation.INTERP_NEAREST), null);
    }
    set(sourceOverlay, 0, 0);
}
Also used : RenderedImage(java.awt.image.RenderedImage) PlanarImage(javax.media.jai.PlanarImage) BufferedImage(java.awt.image.BufferedImage)

Example 9 with PlanarImage

use of javax.media.jai.PlanarImage in project vcell by virtualcell.

the class ROIMultiPaintManager method padXYUShort.

public static short[] padXYUShort(short[] shortArr, int numX, int numY, int left, int right, int top, int bottom) {
    BufferedImage bufferedImage = new BufferedImage(numX, numY, BufferedImage.TYPE_USHORT_GRAY);
    short[] shortData = ((DataBufferUShort) bufferedImage.getRaster().getDataBuffer()).getData();
    System.arraycopy(shortArr, 0, shortData, 0, shortArr.length);
    PlanarImage planarImage = BorderDescriptor.create(bufferedImage, left, right, top, bottom, null, null).getRendering();
    return ((DataBufferUShort) planarImage.getData().getDataBuffer()).getData();
}
Also used : DataBufferUShort(java.awt.image.DataBufferUShort) BufferedImage(java.awt.image.BufferedImage) PlanarImage(javax.media.jai.PlanarImage)

Example 10 with PlanarImage

use of javax.media.jai.PlanarImage in project vcell by virtualcell.

the class ROIMultiPaintManager method resizeXYByte.

public static PlanarImage resizeXYByte(byte[] byteArr, int numX, int numY, Float scaleX, Float scaleY) {
    BufferedImage bufferedImage = new BufferedImage(numX, numY, BufferedImage.TYPE_BYTE_INDEXED, getContrastIndexColorModel());
    byte[] byteData = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
    System.arraycopy(byteArr, 0, byteData, 0, byteArr.length);
    PlanarImage planarImage = ScaleDescriptor.create(bufferedImage, scaleX, scaleY, 0f, 0f, new InterpolationNearest(), null);
    return planarImage;
// PaddedInfo paddedInfo = new PaddedInfo();
// paddedInfo.paddedArray = ((DataBufferByte)planarImage.getData().getDataBuffer()).getData();
// paddedInfo.paddedISize = new ISize(planarImage.getWidth(), planarImage.getHeight(), 1);
// return paddedInfo;
}
Also used : InterpolationNearest(javax.media.jai.InterpolationNearest) DataBufferByte(java.awt.image.DataBufferByte) BufferedImage(java.awt.image.BufferedImage) PlanarImage(javax.media.jai.PlanarImage)

Aggregations

PlanarImage (javax.media.jai.PlanarImage)10 BufferedImage (java.awt.image.BufferedImage)6 LookupTableJAI (javax.media.jai.LookupTableJAI)3 DataBufferByte (java.awt.image.DataBufferByte)2 DataBufferUShort (java.awt.image.DataBufferUShort)2 RenderedImage (java.awt.image.RenderedImage)2 InterpolationNearest (javax.media.jai.InterpolationNearest)2 RenderedOp (javax.media.jai.RenderedOp)2 Point (java.awt.Point)1