0
votes

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
Are you sure that the data is not compressed?Christopher Oezbek
@ChristopherOezbek, how do you check if the data is compressed? I tried to check against if it was "Lossy", but it returned false. Not sure if there's something else I should be looking for?atarng
I did see that there might be RLE Compression? dicom.nema.org/medical/dicom/2016c/output/chtml/part05/… I'm not quite sure how to detect or handle that if such is the case.atarng

1 Answers

1
votes

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