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

JPEG 2000 / JP2K compression broken if verification is enabled #533

Closed
bjoernalbers opened this issue Jan 26, 2017 · 4 comments
Closed

JPEG 2000 / JP2K compression broken if verification is enabled #533

bjoernalbers opened this issue Jan 26, 2017 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bjoernalbers
Copy link

Hello,

at first I was surprised by the excellent compression ratio of 30:1 :-)
But then I've noticed that all images where empty when JPEG 2000 compression is selected:

osirix

However, JPEG-LS does work.

Snipped from server.log:

2017-01-26 16:11:37,088 INFO  [org.dcm4che3.net.Dimse] (EE-ManagedExecutorService-default-Thread-5) DCM4CHEE<-albers(1) >> 1:C-STORE-RQ[pcid=41, prior=2
  cuid=1.2.840.10008.5.1.4.1.1.2 - CT Image Storage
  iuid=1.2.392.200036.9116.2.6.1.3268.2060189428.1481864242.64849 - ?
  tsuid=1.2.840.10008.1.2.1 - Explicit VR Little Endian
2017-01-26 16:11:37,112 DEBUG [org.dcm4che3.net.Dimse] (EE-ManagedExecutorService-default-Thread-5) Command:
(0000,0002) UI [1.2.840.10008.5.1.4.1.1.2] AffectedSOPClassUID
(0000,0100) US [1] CommandField
(0000,0110) US [1] MessageID
(0000,0700) US [2] Priority
(0000,0800) US [1] CommandDataSetType
(0000,1000) UI [1.2.392.200036.9116.2.6.1.3268.2060189428.1481864242.64849] Af

2017-01-26 16:11:37,148 DEBUG [org.dcm4che3.imageio.codec.Transcoder] (EE-ManagedExecutorService-default-Thread-5) Compressor: com.sun.media.imageioimpl.plugins.jpeg2000.J2KImage
WriterCodecLib
2017-01-26 16:11:37,152 DEBUG [org.dcm4che3.imageio.codec.Transcoder] (EE-ManagedExecutorService-default-Thread-5) Verifier: com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderCodecLib
2017-01-26 16:11:42,272 DEBUG [org.dcm4che3.imageio.codec.Transcoder] (EE-ManagedExecutorService-default-Thread-5) Compressed frame #1 30.826:1 in 85 ms
2017-01-26 16:11:42,353 DEBUG [org.dcm4che3.imageio.codec.Transcoder] (EE-ManagedExecutorService-default-Thread-5) Verified compressed frame #1 in 81 ms - max pixel value error: 0

Image-Metadata:

$ gdcminfo D0DD6998 
MediaStorage is 1.2.840.10008.5.1.4.1.1.2 [CT Image Storage]
TransferSyntax is 1.2.840.10008.1.2.4.90 [JPEG 2000 Image Compression (Lossless Only)]
NumberOfDimensions: 2
Dimensions: (1256,1256,1)
SamplesPerPixel    :1
BitsAllocated      :16
BitsStored         :16
HighBit            :15
PixelRepresentation:1
ScalarType found   :INT16
PhotometricInterpretation: MONOCHROME2 
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.4.90
Origin: (-76.4545,35.7079,-820.2)
Spacing: (0.12,0.12,1)
DirectionCosines: (1,0,0,0,0,-1)
Rescale Intercept/Slope: (0,1)
Orientation Label: CORONAL

$ du -h D0DD6998 
4,0K    D0DD6998

The archive runs on Ubuntu 16.04 following the official installation instructions.

$ uname -a
Linux gandalf 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ md5sum /opt/wildfly/modules/com/sun/media/imageio/main/* 2>/dev/null
a427c487f4a0f18a7aead09d5162b1ef  /opt/wildfly/modules/com/sun/media/imageio/main/clibwrapper_jiio-1.2-pre-dr-b04.jar
c9b9b705c5c95af91d8effcfaff8b13e  /opt/wildfly/modules/com/sun/media/imageio/main/jai_imageio-1.2-pre-dr-b04.jar
b4d4e731930dd774d4437274d0275a69  /opt/wildfly/modules/com/sun/media/imageio/main/module.xml

$ md5sum /opt/wildfly/modules/com/sun/media/imageio/main/lib/linux-x86_64/libclib_jiio.so 
8fb2ddb06382fb02beb1b0a11a5acd43  /opt/wildfly/modules/com/sun/media/imageio/main/lib/linux-x86_64/libclib_jiio.so

Björn

@gunterze
Copy link
Member

The used J2K codec is not maintained by dcm4che - anyway I will try to reproduce the issue, if you provide a test image which compression/decompression failed.

@bjoernalbers
Copy link
Author

Thanks, I'll send some images.
Basically all images are affected so far.

@bjoernalbers
Copy link
Author

@gunterze Here are the images... https://dl.dropboxusercontent.com/u/150292/dcm4chee-arc-light-issue533.tgz

PS: I didn't test this with the dcm4che's official docker image but it might also be affected. So far each image is "empty" when I select JPEG2000-compression.

@gunterze gunterze changed the title JPEG 2000 / JP2K compression broken in version 5.8.1 JPEG 2000 / JP2K compression broken if verification is enabled Mar 9, 2017
@gunterze
Copy link
Member

gunterze commented Mar 9, 2017

The error only occurs if verification is enabled by dcmImageWriteParam: maxPixelValueError=0.0. It's caused by an unbalanced ImageInputStream.mark() in the setInput(Object input,..) method of com.sun.media.imageioimpl.plugins.jpeg2000/J2KImageReaderCodecLib, so a client cannot rely to restore previously marked stream position by ImageInputStream.reset(). Fixed by commit 51499c9

@gunterze gunterze closed this as completed Mar 9, 2017
@gunterze gunterze self-assigned this Mar 9, 2017
@gunterze gunterze added the bug Something isn't working label Mar 9, 2017
@gunterze gunterze added this to the 5.9.3 milestone Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants