ImagingDataCommons / highdicom

High-level DICOM abstractions for the Python programming language
https://highdicom.readthedocs.io
MIT License
164 stars 34 forks source link

Correctly account for Cr and Cb subsampling for native YBR_FULL_422 #242

Closed CPBridge closed 8 months ago

CPBridge commented 1 year ago

Addresses #235

Occasionally the YBR_FULL_422 photometric interpretation is used for native encoded pixels. When this occurs, the calculation of bytes per frame needs to account for the subsampling of the colour (Cr and Cb) channels. The logic is given here as:

Rows (0028,0010) Columns (0028,0011) Number of Frames (0028,0008) * 2

This seems to work correctly with the sample file shared in #235.

CPBridge commented 1 year ago

Note that tests are currently failing for reasons unrelated to this PR, see #243 . We should wait on #244 before proceeding with this PR

CPBridge commented 12 months ago

Note that issues #235 and #241 seem to be resolved by this change. However, there is more to think through before merging:

CPBridge commented 8 months ago

Added a test and pushing this out so that it makes it into the next release (0.22.0). I will try to fix the colour space issue soon, but for now users can retrieve the frames without colour correction and then use eg pillow to convert YBR to RGB

CPBridge commented 8 months ago

Merging, since tests are failing for reasons unrelated to this PR