Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DICOM: Add support for nested sequences #2558

Merged
merged 1 commit into from
Sep 13, 2020
Merged

DICOM: Add support for nested sequences #2558

merged 1 commit into from
Sep 13, 2020

Conversation

Malvineous
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practices as demonstrated in the repository.

Description

This fixes #2534.

The DICOM code was not handling sequences, which are like folders. Inside a sequence/folder, attributes like the image dimensions can be changed, but these only apply to images within the sequence/folder. Once exiting the sequence and returning to the parent "folder", the previous image attributes must be restored.

Issue #2534 has a sample image file that initially sets the image dimensions to 2101x2101, however it then begins a sequence for a thumbnail, which sets the dimensions to 64x64 and has some pixel data. After exiting that sequence, the original image dimensions are meant to be restored, however this was not happening. As a result the main image was read as 64x64 and the unused pixel data was then treated as further DICOM header information for a subsequent image, causing unrelated errors.

This PR uses ImageMagick's linked list implementation to push the relevant image attributes onto a stack each time a sequence is encountered, so that when the sequence is exited, the original attributes are restored. It fixes the issue and allows the sample image to be read correctly (both the thumbnail and the main image).

A sequence is like a folder, so attribute changes within the sequence/folder
should only apply to images contained within.  The previous attributes must be
restored once the sequence ends and processing returns to the parent "folder".

Fixes #2534.
@urban-warrior urban-warrior merged commit 8101670 into ImageMagick:master Sep 13, 2020
urban-warrior pushed a commit to ImageMagick/ImageMagick6 that referenced this pull request Sep 13, 2020
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 20, 2020
2020-09-19  7.0.10-30  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.10-30 GIT revision 17641:ab95f7264:20200919

2020-09-07  7.0.10-30  <quetzlzacatenango@image...>
  * Add endian support to JSON coder.
  * Regression: MapCache type cache allocation skipped (reference
    ImageMagick/ImageMagick6#97).
  * Some DCM images include a thumbnail (reference
    ImageMagick/ImageMagick#2558).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

New DICOM variant (insufficient image data @ error/dcm.c/ReadDCMImage/3309)
2 participants