Viewers icon indicating copy to clipboard operation
Viewers copied to clipboard

Image discoloration for JPEG encapsulated in DICOM received from Orthanc dicom-web endpoint

Open cutecycle opened this issue 6 years ago • 16 comments

I have seen other entries for this issue, however:

  • I've done a C-MOVE of the study from this instance to a separate orthanc server, and there was no discoloration in its OHIF Viewer
  • I've viewed the DICOM sent to this in Horus, and there was no discoloration

I think at this point it's an OHIF Viewer issue, rather than an orthanc issue. I'm not entirely sure if the viewing is affected by whether or not the image is HDR, the photometric interpretation, the compression bits, the or the endianness, or sending an image that is "compressed" as "uncompressed," because technically we didn't compress the image we wrapped.

Bug Report

Describe the Bug

When viewing a JPEG encapsulated in DICOM and sent to an Orthanc server, the image appears discolored.

What steps can we follow to reproduce the bug?

  1. Send either of the following DICOM files:
  2. Navigate to the patient entry in the ohif viewer.

I've exposed a public ohif viewer server at https://ohif-test.immd.club. Its DICOM destination is [email protected]:4242.

docker-compose.ohif.yml

version: '3.6'
services:
  mongo:
    container_name: mongo
    image: "mongo:latest"
    restart: always
  proxy:
    container_name: nginx
    image: nginx
    restart: always
    volumes:
      - ./configs/ohif-config/nginx.conf:/etc/nginx/conf.d/default.conf
  caddy:
    container_name: caddy
    restart: always
    image: "imagemovermd/caddy:latest"
    build: 
      context: .
      dockerfile: ./configs/caddy-config/Dockerfile
    volumes:
      - ./configs/ohif-config/caddy/certs:/root/.caddy  # to save certificates on disk
      - ./configs/ohif-config/Caddyfile:/etc/Caddyfile  # to mount custom Caddyfile
    environment:
      - CADDYPATH=${HOME}/.caddy
      - CADDY_DESTINATION_PORT=${CADDY_DESTINATION_PORT:-80}
      - CADDY_DESTINATION=${CADDY_DESTINATION:-nginx}
      - CADDY_FQDN=${CADDY_FQDN:-ohif-test.immd.club}
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      - proxy
  orthanc:
    container_name: orthanc
    image: jodogne/orthanc-plugins@sha256:23170f256c71018f1f167bbf9892841ca281a2a6c28092989f26939e924552c3
    restart: always
    ports:
      - "4242:4242"
    command: ["--verbose","/etc/orthanc/orthanc.json" ]
    # network_mode: host
    volumes:
       - ./configs/ohif-config/orthanc.json:/etc/orthanc/orthanc.json
  viewer:
    container_name: viewer
    image: ohif/viewer@sha256:8b333bc716760a5b48fc0be1948b66de60fc539a14c9f4b2f95df03b0528b7e8
    restart: always
    environment:
      - MONGO_URL=mongodb://mongo:27017/ohif
      - PUBLIC_URL=http://34.220.35.158/
    extra_hosts:
      - "pacsip:127.0.0.1"
      - "pacsIP:127.0.0.1"
    volumes:
      - ./configs/ohif-config/ohif.json:/app/app.json
      - ./configs/ohif-config/ohif.js:/usr/share/nginx/html/app-config.js

Docker images:

Container       Repository           Tag         Image Id      Size  
---------------------------------------------------------------------
caddy       imagemovermd/caddy   latest        d86693c25e35   126 MB 
mongo       mongo                latest        a0e2e64ac939   347 MB 
nginx       nginx                latest        f7bb5701a33c   120 MB 
orthanc     <none>               <none>        2470fac3bb72   192 MB 
viewer      ohif/viewer          v2.2.0.5809   9349ecd0cf11   38.8 MB

Exif data:

# zoey.jpg
ExifTool Version Number         : 10.80
File Name                       : 2.jpg
Directory                       : .
File Size                       : 126 kB
File Modification Date/Time     : 2020:01:09 19:54:31+00:00
File Access Date/Time           : 2020:01:09 19:54:25+00:00
File Inode Change Date/Time     : 2020:01:09 19:54:31+00:00
File Permissions                : rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 6 Plus
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : 10.3.1
Modify Date                     : 2017:06:28 00:07:17
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/4
F Number                        : 2.2
Exposure Program                : Program AE
ISO                             : 160
Exif Version                    : 0221
Date/Time Original              : 2017:06:28 00:07:17
Create Date                     : 2017:06:28 00:07:17
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/4
Aperture Value                  : 2.2
Brightness Value                : -2.841885824
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Auto, Did not fire
Focal Length                    : 4.2 mm
Subject Area                    : 1631 1223 1795 1077
Run Time Flags                  : Valid
Run Time Value                  : 34700732138750
Run Time Epoch                  : 0
Run Time Scale                  : 1000000000
Acceleration Vector             : 0.07252224291 -0.9839130435 -0.08616925645
Sub Sec Time Original           : 544
Sub Sec Time Digitized          : 544
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 1220
Exif Image Height               : 1320
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 29 mm
Scene Capture Type              : Standard
Image Unique ID                 : 5246bf598847076e0000000000000000
Lens Info                       : 4.15mm f/2.2
Lens Make                       : Apple
Lens Model                      : iPhone 6 Plus back camera 4.15mm f/2.2
GPS Version ID                  : 2.2.0.0
GPS Latitude Ref                : North
GPS Longitude Ref               : West
GPS Altitude Ref                : Above Sea Level
GPS Time Stamp                  : 04:07:17
GPS Speed Ref                   : km/h
GPS Speed                       : 0.006269935961
GPS Img Direction Ref           : True North
GPS Img Direction               : 94.31746032
GPS Dest Bearing Ref            : True North
GPS Dest Bearing                : 94.31746032
GPS Date Stamp                  : 2017:06:28
GPS Horizontal Positioning Error: 200 m
Compression                     : JPEG (old-style)
Thumbnail Offset                : 2228
Thumbnail Length                : 4240
Image Width                     : 1220
Image Height                    : 1320
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Aperture                        : 2.2
GPS Altitude                    : 31.1 m Above Sea Level
GPS Date/Time                   : 2017:06:28 04:07:17Z
GPS Latitude                    : 28 deg 34' 42.31" N
GPS Longitude                   : 81 deg 12' 29.51" W
GPS Position                    : 28 deg 34' 42.31" N, 81 deg 12' 29.51" W
Image Size                      : 1220x1320
Megapixels                      : 1.6
Run Time Since Power Up         : 9:38:20
Scale Factor To 35 mm Equivalent: 7.0
Shutter Speed                   : 1/4
Create Date                     : 2017:06:28 00:07:17.544
Date/Time Original              : 2017:06:28 00:07:17.544
Thumbnail Image                 : (Binary data 4240 bytes, use -b option to extract)
Circle Of Confusion             : 0.004 mm
Field Of View                   : 63.7 deg
Focal Length                    : 4.2 mm (35 mm equivalent: 29.0 mm)
Hyperfocal Distance             : 1.82 m
Light Value                     : 3.6



# zoey.dcm 

ExifTool Version Number         : 10.80
File Name                       : 2.dcm
Directory                       : .
File Size                       : 128 kB
File Modification Date/Time     : 2020:01:09 19:54:31+00:00
File Access Date/Time           : 2020:01:09 22:53:23+00:00
File Inode Change Date/Time     : 2020:01:09 19:54:31+00:00
File Permissions                : rw-r--r--
File Type                       : DICOM
File Type Extension             : dcm
MIME Type                       : application/dicom
File Meta Info Group Length     : 178
File Meta Info Version          : 0 1
Media Storage SOP Class UID     : Secondary Capture Image Storage
Media Storage SOP Instance UID  : 1.2.826.0.1.3680043.9.3574.999.5.20091354.3.2
Transfer Syntax UID             : JPEG Baseline (Process 1)
Implementation Class UID        : 1.2.40.0.13.1.1
Implementation Version Name     : dcm4che-3.3.7
Specific Character Set          : ISO_IR 100
Image Type                      : ORIGINAL\PRIMARY
Instance Creation Date          : 2020:01:09
Instance Creation Time          : 13:54:25.655
SOP Class UID                   : Secondary Capture Image Storage
SOP Instance UID                : 1.2.826.0.1.3680043.9.3574.999.5.20091354.3.2
Study Date                      : 2020:01:09
Series Date                     : 2020:01:09
Acquisition Date                : 2017:06:28
Content Date                    : 2017:06:28
Study Time                      : 13:54:22.972
Series Time                     : 13:54:22.972
Acquisition Time                : 04:07:17.000
Content Time                    : 04:07:17.000
Accession Number                : 999000000033
Modality                        : VL
Conversion Type                 : SI
Manufacturer                    : ImageMoverMD
Referring Physician Name        : 
Study Description               : DERM PHOTO
Series Description              : PHOTO
Institutional Department Name   : 
Physicians Of Record            : 
Performing Physician Name       : 
Performing Physician ID Sequence: 
Person Identification Code Sequence: 
Institution Name                : 
Code Value                      : 
Coding Scheme Designator        : NPI
Code Meaning                    : Provider ID
End Of Items                    : 
Name Of Physician Reading Study : 
Operators Name                  : 
Manufacturers Model Name        : ImageMover
Patient Name                    : 
Patient ID                      : 123
Issuer Of Patient ID            : 
Patient Birth Date              : 
Patient Sex                     : 
Body Part Examined              : 
Software Version                : 2.0.0
Study Instance UID              : 1.2.826.0.1.3680043.9.3574.999.5.20091354
Series Instance UID             : 1.2.826.0.1.3680043.9.3574.999.5.20091354.3
Study ID                        : 3
Series Number                   : 200
Instance Number                 : 1
Patient Orientation             : 
Laterality                      : 
Samples Per Pixel               : 3
Photometric Interpretation      : YBR_FULL_422
Planar Configuration            : 0
Rows                            : 1320
Columns                         : 1220
Bits Allocated                  : 8
Bits Stored                     : 8
High Bit                        : 7
Pixel Representation            : Unsigned
Lossy Image Compression         : 01
Requesting Physician            : 
Patient Institution Residence   : Outpatient
Pixel Data                      : (Binary data 0 bytes, use -b option to extract)
Start Of Item                   : (Binary data 129398 bytes, use -b option to extract)
End Of Sequence                 : 

dragonquest5

dragonquest.dcm 
ExifTool Version Number         : 10.80
File Name                       : 3.dcm
Directory                       : tmp/pronghorn/uploads
File Size                       : 4.7 MB
File Modification Date/Time     : 2020:01:06 20:48:11+00:00
File Access Date/Time           : 2020:01:06 20:48:11+00:00
File Inode Change Date/Time     : 2020:01:06 20:48:11+00:00
File Permissions                : rw-r--r--
File Type                       : DICOM
File Type Extension             : dcm
MIME Type                       : application/dicom
File Meta Info Group Length     : 178
File Meta Info Version          : 0 1
Media Storage SOP Class UID     : Secondary Capture Image Storage
Media Storage SOP Instance UID  : 1.2.826.0.1.3680043.9.3574.999.8.20061448.8.3
Transfer Syntax UID             : JPEG Baseline (Process 1)
Implementation Class UID        : 1.2.40.0.13.1.1
Implementation Version Name     : dcm4che-3.3.7
Specific Character Set          : ISO_IR 100
Image Type                      : ORIGINAL\PRIMARY
Instance Creation Date          : 2020:01:06
Instance Creation Time          : 14:48:11.355
SOP Class UID                   : Secondary Capture Image Storage
SOP Instance UID                : 1.2.826.0.1.3680043.9.3574.999.8.20061448.8.3
Study Date                      : 2020:01:06
Series Date                     : 2020:01:06
Acquisition Date                : 2019:12:21
Content Date                    : 2019:12:21
Study Time                      : 14:48:05.834
Series Time                     : 14:48:05.834
Acquisition Time                : 23:01:22.000
Content Time                    : 23:01:22.000
Accession Number                : 999000000026
Modality                        : VL
Conversion Type                 : SI
Manufacturer                    : ImageMoverMD
Referring Physician Name        : 
Study Description               : DERM PHOTO
Series Description              : PHOTO
Institutional Department Name   : 
Physicians Of Record            : 
Performing Physician Name       : 
Performing Physician ID Sequence: 
Person Identification Code Sequence: 
Institution Name                : 
Code Value                      : 
Coding Scheme Designator        : NPI
Code Meaning                    : Provider ID
End Of Items                    : 
Name Of Physician Reading Study : 
Operators Name                  : 
Manufacturers Model Name        : ImageMover
Patient Name                    : 
Patient ID                      : 123
Issuer Of Patient ID            : 
Patient Birth Date              : 
Patient Sex                     : 
Body Part Examined              : 
Software Version                : 2.0.0
Study Instance UID              : 1.2.826.0.1.3680043.9.3574.999.8.20061448
Series Instance UID             : 1.2.826.0.1.3680043.9.3574.999.8.20061448.8
Study ID                        : 8
Series Number                   : 200
Instance Number                 : 1
Patient Orientation             : 
Laterality                      : 
Samples Per Pixel               : 3
Photometric Interpretation      : YBR_FULL_422
Planar Configuration            : 0
Rows                            : 4032
Columns                         : 3024
Bits Allocated                  : 8
Bits Stored                     : 8
High Bit                        : 7
Pixel Representation            : Unsigned
Lossy Image Compression         : 01
Requesting Physician            : 
Patient Institution Residence   : Outpatient
Pixel Data                      : (Binary data 0 bytes, use -b option to extract)
Start Of Item                   : (Binary data 4901334 bytes, use -b option to extract)
End Of Sequence                 : 


dragonquest.jpg 
ExifTool Version Number         : 10.80
File Name                       : 3.jpg
Directory                       : tmp/pronghorn/uploads
File Size                       : 4.7 MB
File Modification Date/Time     : 2020:01:06 20:48:07+00:00
File Access Date/Time           : 2020:01:06 20:48:10+00:00
File Inode Change Date/Time     : 2020:01:06 20:48:10+00:00
File Permissions                : rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : Google
Camera Model Name               : Pixel 3a
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : HDR+ 1.0.265696846zdh
Modify Date                     : 2019:12:21 17:01:22
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/60
F Number                        : 1.8
Exposure Program                : Program AE
ISO                             : 157
Exif Version                    : 0231
Date/Time Original              : 2019:12:21 17:01:22
Create Date                     : 2019:12:21 17:01:22
Offset Time                     : -06:00
Offset Time Original            : -06:00
Offset Time Digitized           : -06:00
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/60
Aperture Value                  : 1.8
Brightness Value                : 1.95
Exposure Compensation           : 0
Max Aperture Value              : 1.8
Subject Distance                : 0.659 m
Metering Mode                   : Center-weighted average
Flash                           : Off, Did not fire
Focal Length                    : 4.4 mm
Warning                         : [minor] Unrecognized MakerNotes
Sub Sec Time                    : 202982
Sub Sec Time Original           : 202982
Sub Sec Time Digitized          : 202982
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 4032
Exif Image Height               : 3024
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Custom Rendered                 : Custom
Exposure Mode                   : Auto
White Balance                   : Auto
Digital Zoom Ratio              : 0
Focal Length In 35mm Format     : 27 mm
Scene Capture Type              : Standard
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
Subject Distance Range          : Macro
GPS Version ID                  : 2.2.0.0
GPS Latitude Ref                : North
GPS Longitude Ref               : West
GPS Altitude Ref                : Above Sea Level
GPS Time Stamp                  : 23:01:22
GPS Dilution Of Precision       : 13.544
GPS Processing Method           : fused
GPS Date Stamp                  : 2019:12:21
Compression                     : JPEG (old-style)
Thumbnail Offset                : 18664
Thumbnail Length                : 5643
Image Width                     : 3024
Image Height                    : 4032
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Aperture                        : 1.8
GPS Altitude                    : 251 m Above Sea Level
GPS Date/Time                   : 2019:12:21 23:01:22Z
GPS Latitude                    : 43 deg 6' 11.18" N
GPS Longitude                   : 89 deg 17' 47.59" W
GPS Position                    : 43 deg 6' 11.18" N, 89 deg 17' 47.59" W
Image Size                      : 3024x4032
Megapixels                      : 12.2
Scale Factor To 35 mm Equivalent: 6.1
Shutter Speed                   : 1/60
Create Date                     : 2019:12:21 17:01:22.202982-06:00
Date/Time Original              : 2019:12:21 17:01:22.202982-06:00
Modify Date                     : 2019:12:21 17:01:22.202982-06:00
Thumbnail Image                 : (Binary data 5643 bytes, use -b option to extract)
Circle Of Confusion             : 0.005 mm
Depth Of Field                  : 0.43 m (0.51 - 0.94 m)
Field Of View                   : 67.4 deg
Focal Length                    : 4.4 mm (35 mm equivalent: 27.0 mm)
Hyperfocal Distance             : 2.22 m
Light Value                     : 6.9

dicom.zip

cutecycle avatar Jan 09 '20 23:01 cutecycle

Thanks so much for the easy reproduction!

What toolkit / commands did you use to encapsulate it in DICOM? It says dcm4che-3.3.7 in your data above. Does it also look weird if you encode it with img2dcm from dcmtk? Could you provide the jpeg itself in case it has something to do with HDR?

I believe the viewer that comes with Orthanc also uses Cornerstone but it does some conversions ahead of time with GDCM or something, that might account for the difference.

Does it also look weird in here? https://rawgit.com/cornerstonejs/cornerstoneWADOImageLoader/master/examples/dicomfile/index.html

This is what I get when I convert a JPEG to DICOM using img2dcm:

SpecificCharacterSet : "ISO_IR 100"
SOPClassUID : "1.2.840.10008.5.1.4.1.1.7" [ Secondary Capture Image Storage ]
SOPInstanceUID : "1.2.276.0.7230010.3.1.4.0.31362.1578644814.976007"
ConversionType : "WSD"
StudyInstanceUID : "1.2.276.0.7230010.3.1.2.0.31362.1578644814.976006"
SeriesInstanceUID : "1.2.276.0.7230010.3.1.3.0.31362.1578644814.976005"
SamplesPerPixel : 3
PhotometricInterpretation : "YBR_FULL_422"
PlanarConfiguration : 0
Rows : 3264
Columns : 1836
BitsAllocated : 8
BitsStored : 8
HighBit : 7
PixelRepresentation : 0
LossyImageCompression : "01"
LossyImageCompressionMethod : "ISO_10918_1"
PixelData : encapsulated pixel data with 0 offsets and 1 fragments

and it appears correctly in the viewer (tested via https://viewer.ohif.org/local).

swederik avatar Jan 10 '20 08:01 swederik

No problem!

here are the original jpegs: dragonquest: 6

zoey:

2

jpegs.zip

cutecycle avatar Jan 10 '20 21:01 cutecycle

img2dcm of zoey.jpg, viewed in horos:

image

cutecycle avatar Jan 10 '20 21:01 cutecycle

Additional details: Is this a function of PixelData?

http://ohif-test.immd.club:8042/app/explorer.html#instance?uuid=841baf55-b2a07087-c4fa7a0c-7eccaf94-0e9790da

image

Orthanc Explorer's viewer gives a black screen for JPEG-based instance previews:

image

cutecycle avatar Jan 21 '20 20:01 cutecycle

additional data:

  • the OHIF preview viewer seems to convert everything to PNG at the final stage. even jpegs

cutecycle avatar Jan 22 '20 21:01 cutecycle

I'm not sure I understand what you mean by OHIF preview viewer. Do you mean the rendered thumbnails?

dannyrb avatar Jan 22 '20 21:01 dannyrb

@dannyrb Yes: rendered thumbnails etc. The (react-cornerstone-viewport?) that previews an image from a series: image

If I download the image from this dialog, image

It comes out as image.jpg, but the actual data is a PNG: image

○ → exiftool /Users/cutecycle/Downloads/image\(2\).jpg 
ExifTool Version Number         : 11.59
File Name                       : image(2).jpg
Directory                       : /Users/cutecycle/Downloads
File Size                       : 397 kB
File Modification Date/Time     : 2020:01:22 15:02:07-06:00
File Access Date/Time           : 2020:01:22 15:02:13-06:00
File Inode Change Date/Time     : 2020:01:22 15:02:10-06:00
File Permissions                : rw-r--r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 512
Image Height                    : 512
Bit Depth                       : 8
Color Type                      : RGB with Alpha
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Image Size                      : 512x512
Megapixels                      : 0.262```

cutecycle avatar Jan 22 '20 21:01 cutecycle

Hi, I have been using the viewer for a few weeks and have ecountered the same problem. @cutecycle I think is not related to the viewer itself but to the image, in our case changing the jpeg codification type from JPEGBaseline to LittlelEndianExplicit while generating the DICOM did the trick! I am no expert on the matter but hopefully you or anyone that gets here from google could find some direction to look into.

jajimgme avatar Apr 24 '20 10:04 jajimgme

We are also facing the same problem. We asked the supplier to change the devices' compression to JPEGBaseline in order to save some space. Now we are faced with this.

Changing it back to LittleEndian would work like @jajimgme, but that would mean for us waiting weeks for the suppliers to come back.

Does anybody know what is causing the problem?

Artboard@1x

jeffmartina avatar Jun 25 '20 14:06 jeffmartina

@jbocce ditto

sedghi avatar Oct 13 '23 17:10 sedghi

This is still an issue. Interestingly, if the provided DICOM files are loaded using localbasic, the problem(s) do NOT occur.

jbocce avatar Oct 13 '23 18:10 jbocce

Wait for Orthanc fix

@sedghi provide their issue summary linked here

james-hanks avatar Nov 15 '23 18:11 james-hanks

For anyone interested, you can read more about this issue here https://discourse.orthanc-server.org/t/orthanc-convert-ybr-to-rgb-but-does-not-change-metadata/3533/17

sedghi avatar Nov 15 '23 18:11 sedghi

@jeffmartina Can you try again with latest master branch push, I think we fixed this

sedghi avatar Jan 09 '24 18:01 sedghi

I only get these green images if OHIF data source is set to "dicom-json". It works just fine if it is configured to "dicom-web". I'd like to be able to use the former to work because I want to use the "Preloading" feature which I understand is only available with dicom-json

2pulses avatar Apr 19 '24 20:04 2pulses

We just release the OHIF 3.8, you can find more details here https://ohif.org/release-notes/3p8/ If you still encounter this issue in 3.8, please re-open this.

sedghi avatar May 01 '24 17:05 sedghi