Search in sources :

Example 1 with PatchJPEGLSImageInputStream

use of org.dcm4che3.imageio.codec.jpeg.PatchJPEGLSImageInputStream in project dcm4che by dcm4che.

the class DicomImageReader method iisOfFrame.

/**
 * Generate an image input stream for the given frame, -1 for all frames (video, multi-component single frame)
 * Does not necessarily support the length operation without seeking/reading to the end of the input.
 *
 * @param frameIndex
 * @return
 * @throws IOException
 */
public ImageInputStream iisOfFrame(int frameIndex) throws IOException {
    ImageInputStream iisOfFrame;
    if (epdiis != null) {
        seekFrame(frameIndex);
        iisOfFrame = epdiis;
    } else if (pixelDataFragments == null) {
        return null;
    } else {
        iisOfFrame = new SegmentedInputImageStream(iis, pixelDataFragments, frames == 1 ? -1 : frameIndex);
        ((SegmentedInputImageStream) iisOfFrame).setImageDescriptor(imageDescriptor);
    }
    return patchJpegLS != null ? new PatchJPEGLSImageInputStream(iisOfFrame, patchJpegLS) : iisOfFrame;
}
Also used : SegmentedInputImageStream(org.dcm4che3.imageio.stream.SegmentedInputImageStream) PatchJPEGLSImageInputStream(org.dcm4che3.imageio.codec.jpeg.PatchJPEGLSImageInputStream) PatchJPEGLSImageInputStream(org.dcm4che3.imageio.codec.jpeg.PatchJPEGLSImageInputStream) EncapsulatedPixelDataImageInputStream(org.dcm4che3.imageio.stream.EncapsulatedPixelDataImageInputStream) FileImageInputStream(javax.imageio.stream.FileImageInputStream) ImageInputStream(javax.imageio.stream.ImageInputStream)

Example 2 with PatchJPEGLSImageInputStream

use of org.dcm4che3.imageio.codec.jpeg.PatchJPEGLSImageInputStream in project dcm4che by dcm4che.

the class Decompressor method decompressFrame.

@SuppressWarnings("resource")
protected BufferedImage decompressFrame(ImageInputStream iis, int index) throws IOException {
    SegmentedInputImageStream siis = new SegmentedInputImageStream(iis, pixeldataFragments, index);
    siis.setImageDescriptor(imageDescriptor);
    decompressor.setInput(patchJpegLS != null ? new PatchJPEGLSImageInputStream(siis, patchJpegLS) : siis);
    readParam.setDestination(bi);
    long start = System.currentTimeMillis();
    bi = decompressor.read(0, readParam);
    long end = System.currentTimeMillis();
    if (LOG.isDebugEnabled())
        LOG.debug("Decompressed frame #{} 1:{} in {} ms", new Object[] { index + 1, (float) sizeOf(bi) / siis.getStreamPosition(), end - start });
    return bi;
}
Also used : SegmentedInputImageStream(org.dcm4che3.imageio.stream.SegmentedInputImageStream) PatchJPEGLSImageInputStream(org.dcm4che3.imageio.codec.jpeg.PatchJPEGLSImageInputStream)

Example 3 with PatchJPEGLSImageInputStream

use of org.dcm4che3.imageio.codec.jpeg.PatchJPEGLSImageInputStream in project dcm4chee-arc-light by dcm4che.

the class DecompressSupport method decompressFrame.

protected BufferedImage decompressFrame(int frameIndex) throws IOException {
    if (encapsulatedPixelData.isEndOfStream())
        throw new IOException("Number of data fragments not sufficient for number of frames in requested object");
    decompressor.setInput(decompressorParam.patchJPEGLS != null ? new PatchJPEGLSImageInputStream(encapsulatedPixelData, decompressorParam.patchJPEGLS) : encapsulatedPixelData);
    decompressParam.setDestination(bi);
    long start = System.currentTimeMillis();
    bi = decompressor.read(0, decompressParam);
    long end = System.currentTimeMillis();
    if (LOG.isDebugEnabled())
        LOG.debug("Decompressed frame #{} 1:{} in {} ms", frameIndex + 1, (float) sizeOf(bi) / encapsulatedPixelData.getStreamPosition(), end - start);
    encapsulatedPixelData.seekNextFrame();
    return bi;
}
Also used : PatchJPEGLSImageInputStream(org.dcm4che3.imageio.codec.jpeg.PatchJPEGLSImageInputStream) IOException(java.io.IOException)

Aggregations

PatchJPEGLSImageInputStream (org.dcm4che3.imageio.codec.jpeg.PatchJPEGLSImageInputStream)3 SegmentedInputImageStream (org.dcm4che3.imageio.stream.SegmentedInputImageStream)2 IOException (java.io.IOException)1 FileImageInputStream (javax.imageio.stream.FileImageInputStream)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1 EncapsulatedPixelDataImageInputStream (org.dcm4che3.imageio.stream.EncapsulatedPixelDataImageInputStream)1