Getting PixelData of Multiframe (PaletteColor) Dicom File. fo-dicom

851 views Asked by At

Currently when I'm grabbing the pixel data from this dicom file, it seems to not match the provided image resolution.

As an example, the image width and height might be: W: 600, H:430 which would make me think that the expected total size would be 258,000 elements but when I get the pixel data it's only 50104 elements.

What perplexes me is that there are LESS elements in the array than the file resolution. I was expecting that if there was a mismatch, it would possible because all of the frames were grouped into the same buffer, and I might need to subdivide the pixel data by the number of frames, but to have not enough elements to cover the image resolution? I am a bit at a loss.

The dicom file pixel data is provided from this class:

https://fo-dicom.github.io/html/cfa9fe02-c413-ea1f-52df-dd1a6f5b71cf.htm

Where each pixel is a byte that is used to look up the index of a Color Lookup Table.

Code Sample

protected override byte[] GetPixelDataInternal(GrayscalePixelDataU8 pixelData, DicomDataset dicomDataset)
{
    long totalDimensions = pixelData.Width * pixelData.Height;
    DicomPixelData header = DicomPixelData.Create(dicomDataset);

    // These uncompressed framesize matches total dimensions
    Debug.Log($"Uncompressed Frame Size: {header.UncompressedFrameSize}");
    Debug.Log($"GetPixelDataInternal: {pixelData.Width} x {pixelData.Height} Total: {totalDimensions}");

    // pixelData.Data.Length does not match total length
    Debug.Log($"PixelDataLength: {pixelData.Data.Length} ");

    // It says it is not lossy.
    Debug.Log($"IsLossy: {header.IsLossy}");

    // ...
}

Desired behavior
Opening and rendering a multiframe dicom image with photometric interpretation PaletteColor, using the fo-dicom library.

1

There are 1 answers

0
atarng On

Turns out it was indeed because the Transfer Syntax was RLELossless, and the data needed to be decoded.

See DicomTranscoder from fo-dicom:
https://fo-dicom.github.io/html/f94d5b29-c69f-c0c7-6443-1b001cfc91ec.htm