DicomImageReader and 12-bit monochrome images

49 views
Skip to first unread message

David Maffitt

unread,
Oct 2, 2019, 11:44:12 AM10/2/19
to dcm4che
I am puzzled by org.dcm4che3.imageio.plugins.dcm.DicomImageReader's handling of Monochrome images (5.18.1)

In BufferedImage read(int frameIndex, ImageReadParam param), there is the fragment

        ColorModel cm;
       
if (pmi.isMonochrome()) {
           
int[] overlayGroupOffsets = getActiveOverlayGroupOffsets(param);
           
byte[][] overlayData = new byte[overlayGroupOffsets.length][];
           
for (int i = 0; i < overlayGroupOffsets.length; i++) {
                overlayData
[i] = extractOverlay(overlayGroupOffsets[i], raster);
           
}
            cm
= createColorModel(8, DataBuffer.TYPE_BYTE);
           
SampleModel sm = createSampleModel(DataBuffer.TYPE_BYTE, false);
            raster
= applyLUTs(raster, frameIndex, param, sm, 8);
           
for (int i = 0; i < overlayGroupOffsets.length; i++) {
                applyOverlay
(overlayGroupOffsets[i],
                        raster
, frameIndex, param, 8, overlayData[i]);
           
}
       
} else {
            cm
= createColorModel(bitsStored, dataType);
       
}
       
return new BufferedImage(cm, raster , false, null);



This forces the data into 8-bits regardless of bitsStored.  Is this necessary/intentional?  We lose the original DataBuffer.TYPE_USHORT. This is a surprise for downstream pixel editing.

Dave

Gunter Zeilinger

unread,
Oct 3, 2019, 11:55:24 AM10/3/19
to dcm...@googlegroups.com
You may use DicomImageReader.readRaster(..) instead DicomImageReader.read(..) and apply the Grayscale Transformations (Modality & VOI LUT) yourself.


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
--
You received this message because you are subscribed to the Google Groups "dcm4che" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dcm4che+u...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages