Bug 44

Summary: Bad interpretation of photometric interpretation "MONOCHROME1"
Product: Orthanc Reporter: Sébastien Jodogne <s.jodogne>
Component: Orthanc CoreAssignee: Sébastien Jodogne <s.jodogne>
Status: RESOLVED FIXED    
Severity: normal    
Priority: ---    
Version: unspecified   
Hardware: All   
OS: All   
Attachments: Monochrome1.dcm
Monochrome2.dcm
4027862789-Invert.png

Description Sébastien Jodogne 2020-06-29 15:12:20 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2017-03-31.09:40:18]

See the following discussion on the forum: https://groups.google.com/d/msg/orthanc-users/V5jCSXNgu0w/raYSUx26AQAJ

"MONOCHROME1" and "MONOCHROME2" are currently taken as synonyms by Orthanc, whereas "MONOCHROME1" should map the lowest value as white instead of black.

Two sample images are attached. Here is a sample Matlab/Octave script that does the expected calculation:

```
monochrome1 = 'bcdd600a-a6a9c522-5f0a6e84-8657c9f3-b76e59b7';
size1 = [ 2010 2446 ];

monochrome2 = 'f00947b7-f61f7164-c93414d1-c6fbda6a-9e92ed20';
size2 = [ 1572 2010 ];

function image = LoadImage(id, size)
  # Download the raw pixel data
  raw = urlread([ 'http://localhost:8042/instances/' id '/content/PixelData/0' ]);

  # Write it to some temporary file
  f = fopen('tmp', 'wb');
  fwrite(f, raw);
  fclose(f);

  # Load back as a Matlab matrix
  f = fopen('tmp', 'r');
  image = fread(f, size, 'uint16');
  fclose(f);
endfunction

colormap(gray);
a = LoadImage(monochrome1, size1); imagesc((max(max(a)) - a)')
#a = LoadImage(monochrome2, size2); imagesc(a')


# Monochrome1 (chest): Raw background is white, should be rendered as black => invert
# Monochrome2 (key): Raw background is white, should be rendered as white
```
Comment 1 Sébastien Jodogne 2020-06-29 15:18:25 CEST
Created attachment 87 [details]
Monochrome1.dcm
Comment 2 Sébastien Jodogne 2020-06-29 15:18:29 CEST
Created attachment 88 [details]
Monochrome2.dcm
Comment 3 Sébastien Jodogne 2020-06-29 15:19:41 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2017-03-31.09:42:42]

As a temporary workaround, it is possible to use the "invert contrast" button in the Orthanc Web Viewer: ![Invert.png](4027862789-Invert.png)
Comment 4 Sébastien Jodogne 2020-06-29 15:19:43 CEST
Created attachment 94 [details]
4027862789-Invert.png
Comment 5 Sébastien Jodogne 2020-06-29 15:19:58 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2017-06-09.14:14:58]

Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)

→ https://hg.orthanc-server.com/orthanc/changeset/e002430baa41