suyashkumar / dicom

⚡High Performance DICOM Medical Image Parser in Go.
MIT License
933 stars 136 forks source link

Add option to skip Element Value processing of PixelData, while preserving roundtrip read/write #256

Closed suyashkumar closed 1 year ago

suyashkumar commented 1 year ago

This addresses some of the discussion in #224. The SkipProcessingPixelDataValue option causes the PixelData bytes to be read into the element, but not processed any further. This option provides an option to save the CPU cycles processing NativePixel data but still gives a roundtrip-able Dataset.

If you want to save both CPU and Memory, you can instead use the SkipPixelData option, which doesn't load the PixelData bytes into memory at all.

In the future, we should consider an option to lazy load/process all Element values if possible.

suyashkumar commented 1 year ago

Right now, this introduces the option API in a way that it can be easily expanded to other tags in the future

func TrySkipProcessingElementValue(tags ...*tag.Tag) ParseOption

However, since it's only implemented for PixelData for now, I may make it specific to PixelData. The long term way to expand this to other tags is to probably implement a lazy loading option for all tags where possible. E.g. until you Get() the value we hold onto the bytes.

Anyway, I'd still like to get this in for those who will find it useful, so will introduce an option specific to PixelData for now.