Unable to convert DICOM image to PNG

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jcarneiro
Posts: 2
Joined: 2019-12-04T14:01:45-07:00
Authentication code: 1152

Unable to convert DICOM image to PNG

Post by jcarneiro » 2019-12-04T14:08:14-07:00

Getting the following error when trying to convert a DICOM image to PNG, on Mac OS:

Code: Select all

convert: invalid colormap index `/iDoc/D20090407/E857.4.20090407122438.0000000012/Imagens037.dcm' @ error/colormap-private.h/ConstrainColormapIndex/35.
That happens only on some specific DICOM images.

Tried to search for that error to try and see if I could use some specific options, for example to select a colormap, but to no avail.

Running identify -verbose got me this:

Code: Select all

Image: /iDoc/D20090407/E857.4.20090407122438.0000000012/Imagens037.dcm
  Format: DCM (Digital Imaging and Communications in Medicine image)
  Class: PseudoClass
  Geometry: 800x564+0+0
  Units: Undefined
  Colorspace: Gray
  Type: Grayscale
  Endianess: LSB
  Depth: 8/16-bit
  Channel depth:
    Gray: 16-bit
  Channel statistics:
    Pixels: 451200
    Gray:
      min: 0  (0)
      max: 68.7315 (0.269535)
      mean: 13.0971 (0.051361)
      standard deviation: 21.7016 (0.0851043)
      kurtosis: 0.263191
      skewness: 1.36268
      entropy: 0.490309
  Colors: 70
  Histogram:
    294302: (  0,  0,  0) #000000 gray(0)
      1951: (  1,  1,  1) #010101 gray(1)
      1473: (  2,  2,  2) #020202 gray(2)
      2348: (  3,  3,  3) #030303 gray(3)
      2844: (  4,  4,  4) #040404 gray(4)
      3248: (  5,  5,  5) #050505 gray(5)
      3576: (  6,  6,  6) #060606 gray(6)
      1806: (  7,  7,  7) #070707 gray(7)
      1879: (  8,  8,  8) #080808 gray(8)
      2661: (  9,  9,  9) #090909 gray(9)
      2528: ( 10, 10, 10) #0A0A0A gray(10)
      2362: ( 11, 11, 11) #0B0B0B gray(11)
      1608: ( 12, 12, 12) #0C0C0C gray(12)
      1526: ( 13, 13, 13) #0D0D0D gray(13)
      2971: ( 14, 14, 14) #0E0E0E gray(14)
      2301: ( 15, 15, 15) #0F0F0F gray(15)
       710: ( 16, 16, 16) #101010 gray(16)
      1521: ( 17, 17, 17) #111111 gray(17)
      2142: ( 18, 18, 18) #121212 gray(18)
      1517: ( 19, 19, 19) #131313 gray(19)
      1578: ( 20, 20, 20) #141414 gray(20)
      1524: ( 21, 21, 21) #151515 gray(21)
       810: ( 22, 22, 22) #161616 gray(22)
      2457: ( 23, 23, 23) #171717 gray(23)
      1588: ( 24, 24, 24) #181818 gray(24)
      1634: ( 25, 25, 25) #191919 gray(25)
      1602: ( 26, 26, 26) #1A1A1A gray(26)
       820: ( 27, 27, 27) #1B1B1B gray(27)
      1639: ( 28, 28, 28) #1C1C1C gray(28)
      1661: ( 29, 29, 29) #1D1D1D gray(29)
       894: ( 30, 30, 30) #1E1E1E gray(30)
      1892: ( 31, 31, 31) #1F1F1F gray(31)
       968: ( 32, 32, 32) #202020 gray(32)
      1896: ( 33, 33, 33) #212121 gray(33)
      2056: ( 34, 34, 34) #222222 gray(34)
      1075: ( 35, 35, 35) #232323 gray(35)
      2272: ( 36, 36, 36) #242424 gray(36)
      2591: ( 37, 37, 37) #252525 gray(37)
      1376: ( 38, 38, 38) #262626 gray(38)
      1413: ( 39, 39, 39) #272727 gray(39)
      4377: ( 40, 40, 40) #282828 gray(40)
      1605: ( 41, 41, 41) #292929 gray(41)
      3275: ( 42, 42, 42) #2A2A2A gray(42)
      1661: ( 43, 43, 43) #2B2B2B gray(43)
      1752: ( 44, 44, 44) #2C2C2C gray(44)
      3402: ( 45, 45, 45) #2D2D2D gray(45)
      4953: ( 46, 46, 46) #2E2E2E gray(46)
      1750: ( 47, 47, 47) #2F2F2F gray(47)
      1694: ( 48, 48, 48) #303030 gray(48)
      3369: ( 49, 49, 49) #313131 gray(49)
      1685: ( 50, 50, 50) #323232 gray(50)
      3481: ( 51, 51, 51) #333333 gray(51)
      5262: ( 52, 52, 52) #343434 gray(52)
      1743: ( 53, 53, 53) #353535 gray(53)
      1868: ( 54, 54, 54) #363636 gray(54)
      1902: ( 55, 55, 55) #373737 gray(55)
      1952: ( 56, 56, 56) #383838 gray(56)
      4010: ( 57, 57, 57) #393939 gray(57)
      2002: ( 58, 58, 58) #3A3A3A gray(58)
      2024: ( 59, 59, 59) #3B3B3B gray(59)
      4203: ( 60, 60, 60) #3C3C3C gray(60)
      2101: ( 61, 61, 61) #3D3D3D gray(61)
      4265: ( 62, 62, 62) #3E3E3E gray(62)
      2130: ( 63, 63, 63) #3F3F3F gray(63)
      2177: ( 64, 64, 64) #404040 gray(64)
      2219: ( 65, 65, 65) #414141 gray(65)
      2219: ( 66, 66, 66) #424242 gray(66)
      6715: ( 67, 67, 67) #434343 gray(67)
      2149: ( 68, 68, 68) #444444 gray(68)
      2235: ( 69, 69, 69) #454545 gray(69)
  Colormap entries: 128
  Colormap:
         0: (  0,  0,  0,255) #000000FF rgba(0,0,0,1)
         1: (  0,  0,  0,255) #000000FF rgba(0,0,0,1)
         2: (  0,  0,  0,255) #000000FF rgba(0,0,0,1)
         3: (  0,  0,  0,255) #000000FF rgba(0,0,0,1)
         4: (  0,  0,  0,255) #000000FF rgba(0,0,0,1)
         5: (  0,  0,  0,255) #000000FF rgba(0,0,0,1)
         6: (  0,  0,  0,255) #000000FF rgba(0,0,0,1)
         7: (  1,  1,  1,255) #010101FF rgba(1,1,1,1)
         8: (  1,  1,  1,255) #010101FF rgba(1,1,1,1)
         9: (  1,  1,  1,255) #010101FF rgba(1,1,1,1)
        10: (  1,  1,  1,255) #010101FF rgba(1,1,1,1)
        11: (  2,  2,  2,255) #020202FF rgba(2,2,2,1)
        12: (  2,  2,  2,255) #020202FF rgba(2,2,2,1)
        13: (  2,  2,  2,255) #020202FF rgba(2,2,2,1)
        14: (  3,  3,  3,255) #030303FF rgba(3,3,3,1)
        15: (  3,  3,  3,255) #030303FF rgba(3,3,3,1)
        16: (  3,  3,  3,255) #030303FF rgba(3,3,3,1)
        17: (  3,  3,  3,255) #030303FF rgba(3,3,3,1)
        18: (  4,  4,  4,255) #040404FF rgba(4,4,4,1)
        19: (  4,  4,  4,255) #040404FF rgba(4,4,4,1)
        20: (  4,  4,  4,255) #040404FF rgba(4,4,4,1)
        21: (  5,  5,  5,255) #050505FF rgba(5,5,5,1)
        22: (  5,  5,  5,255) #050505FF rgba(5,5,5,1)
        23: (  5,  5,  5,255) #050505FF rgba(5,5,5,1)
        24: (  5,  5,  5,255) #050505FF rgba(5,5,5,1)
        25: (  6,  6,  6,255) #060606FF rgba(6,6,6,1)
        26: (  6,  6,  6,255) #060606FF rgba(6,6,6,1)
        27: (  6,  6,  6,255) #060606FF rgba(6,6,6,1)
        28: (  7,  7,  7,255) #070707FF rgba(7,7,7,1)
        29: (  7,  7,  7,255) #070707FF rgba(7,7,7,1)
        30: (  8,  8,  8,255) #080808FF rgba(8,8,8,1)
        31: (  8,  8,  8,255) #080808FF rgba(8,8,8,1)
        32: (  9,  9,  9,255) #090909FF rgba(9,9,9,1)
        33: (  9,  9,  9,255) #090909FF rgba(9,9,9,1)
        34: (  9,  9,  9,255) #090909FF rgba(9,9,9,1)
        35: ( 10, 10, 10,255) #0A0A0AFF rgba(10,10,10,1)
        36: ( 10, 10, 10,255) #0A0A0AFF rgba(10,10,10,1)
        37: ( 11, 11, 11,255) #0B0B0BFF rgba(11,11,11,1)
        38: ( 11, 11, 11,255) #0B0B0BFF rgba(11,11,11,1)
        39: ( 11, 11, 11,255) #0B0B0BFF rgba(11,11,11,1)
        40: ( 12, 12, 12,255) #0C0C0CFF rgba(12,12,12,1)
        41: ( 12, 12, 12,255) #0C0C0CFF rgba(12,12,12,1)
        42: ( 13, 13, 13,255) #0D0D0DFF rgba(13,13,13,1)
        43: ( 13, 13, 13,255) #0D0D0DFF rgba(13,13,13,1)
        44: ( 14, 14, 14,255) #0E0E0EFF rgba(14,14,14,1)
        45: ( 14, 14, 14,255) #0E0E0EFF rgba(14,14,14,1)
        46: ( 14, 14, 14,255) #0E0E0EFF rgba(14,14,14,1)
        47: ( 15, 15, 15,255) #0F0F0FFF rgba(15,15,15,1)
        48: ( 15, 15, 15,255) #0F0F0FFF rgba(15,15,15,1)
        49: ( 15, 15, 15,255) #0F0F0FFF rgba(15,15,15,1)
        50: ( 16, 16, 16,255) #101010FF rgba(16,16,16,1)
        51: ( 17, 17, 17,255) #111111FF rgba(17,17,17,1)
        52: ( 17, 17, 17,255) #111111FF rgba(17,17,17,1)
        53: ( 18, 18, 18,255) #121212FF rgba(18,18,18,1)
        54: ( 18, 18, 18,255) #121212FF rgba(18,18,18,1)
        55: ( 19, 19, 19,255) #131313FF rgba(19,19,19,1)
        56: ( 19, 19, 19,255) #131313FF rgba(19,19,19,1)
        57: ( 20, 20, 20,255) #141414FF rgba(20,20,20,1)
        58: ( 20, 20, 20,255) #141414FF rgba(20,20,20,1)
        59: ( 21, 21, 21,255) #151515FF rgba(21,21,21,1)
        60: ( 21, 21, 21,255) #151515FF rgba(21,21,21,1)
        61: ( 22, 22, 22,255) #161616FF rgba(22,22,22,1)
        62: ( 23, 23, 23,255) #171717FF rgba(23,23,23,1)
        63: ( 23, 23, 23,255) #171717FF rgba(23,23,23,1)
        64: ( 24, 24, 24,255) #181818FF rgba(24,24,24,1)
        65: ( 24, 24, 24,255) #181818FF rgba(24,24,24,1)
        66: ( 25, 25, 25,255) #191919FF rgba(25,25,25,1)
        67: ( 25, 25, 25,255) #191919FF rgba(25,25,25,1)
        68: ( 26, 26, 26,255) #1A1A1AFF rgba(26,26,26,1)
        69: ( 26, 26, 26,255) #1A1A1AFF rgba(26,26,26,1)
        70: ( 27, 27, 27,255) #1B1B1BFF rgba(27,27,27,1)
        71: ( 28, 28, 28,255) #1C1C1CFF rgba(28,28,28,1)
        72: ( 29, 29, 29,255) #1D1D1DFF rgba(29,29,29,1)
        73: ( 29, 29, 29,255) #1D1D1DFF rgba(29,29,29,1)
        74: ( 30, 30, 30,255) #1E1E1EFF rgba(30,30,30,1)
        75: ( 31, 31, 31,255) #1F1F1FFF rgba(31,31,31,1)
        76: ( 31, 31, 31,255) #1F1F1FFF rgba(31,31,31,1)
        77: ( 32, 32, 32,255) #202020FF rgba(32,32,32,1)
        78: ( 33, 33, 33,255) #212121FF rgba(33,33,33,1)
        79: ( 33, 33, 33,255) #212121FF rgba(33,33,33,1)
        80: ( 34, 34, 34,255) #222222FF rgba(34,34,34,1)
        81: ( 35, 35, 35,255) #232323FF rgba(35,35,35,1)
        82: ( 36, 36, 36,255) #242424FF rgba(36,36,36,1)
        83: ( 36, 36, 36,255) #242424FF rgba(36,36,36,1)
        84: ( 37, 37, 37,255) #252525FF rgba(37,37,37,1)
        85: ( 37, 37, 37,255) #252525FF rgba(37,37,37,1)
        86: ( 38, 38, 38,255) #262626FF rgba(38,38,38,1)
        87: ( 39, 39, 39,255) #272727FF rgba(39,39,39,1)
        88: ( 40, 40, 40,255) #282828FF rgba(40,40,40,1)
        89: ( 40, 40, 40,255) #282828FF rgba(40,40,40,1)
        90: ( 41, 41, 41,255) #292929FF rgba(41,41,41,1)
        91: ( 42, 42, 42,255) #2A2A2AFF rgba(42,42,42,1)
        92: ( 42, 42, 42,255) #2A2A2AFF rgba(42,42,42,1)
        93: ( 43, 43, 43,255) #2B2B2BFF rgba(43,43,43,1)
        94: ( 44, 44, 44,255) #2C2C2CFF rgba(44,44,44,1)
        95: ( 45, 45, 45,255) #2D2D2DFF rgba(45,45,45,1)
        96: ( 45, 45, 45,255) #2D2D2DFF rgba(45,45,45,1)
        97: ( 46, 46, 46,255) #2E2E2EFF rgba(46,46,46,1)
        98: ( 46, 46, 46,255) #2E2E2EFF rgba(46,46,46,1)
        99: ( 47, 47, 47,255) #2F2F2FFF rgba(47,47,47,1)
       100: ( 48, 48, 48,255) #303030FF rgba(48,48,48,1)
       101: ( 49, 49, 49,255) #313131FF rgba(49,49,49,1)
       102: ( 49, 49, 49,255) #313131FF rgba(49,49,49,1)
       103: ( 50, 50, 50,255) #323232FF rgba(50,50,50,1)
       104: ( 51, 51, 51,255) #333333FF rgba(51,51,51,1)
       105: ( 51, 51, 51,255) #333333FF rgba(51,51,51,1)
       106: ( 52, 52, 52,255) #343434FF rgba(52,52,52,1)
       107: ( 52, 52, 52,255) #343434FF rgba(52,52,52,1)
       108: ( 53, 53, 53,255) #353535FF rgba(53,53,53,1)
       109: ( 54, 54, 54,255) #363636FF rgba(54,54,54,1)
       110: ( 55, 55, 55,255) #373737FF rgba(55,55,55,1)
       111: ( 56, 56, 56,255) #383838FF rgba(56,56,56,1)
       112: ( 57, 57, 57,255) #393939FF rgba(57,57,57,1)
       113: ( 57, 57, 57,255) #393939FF rgba(57,57,57,1)
       114: ( 58, 58, 58,255) #3A3A3AFF rgba(58,58,58,1)
       115: ( 59, 59, 59,255) #3B3B3BFF rgba(59,59,59,1)
       116: ( 60, 60, 60,255) #3C3C3CFF rgba(60,60,60,1)
       117: ( 61, 61, 61,255) #3D3D3DFF rgba(61,61,61,1)
       118: ( 62, 62, 62,255) #3E3E3EFF rgba(62,62,62,1)
       119: ( 62, 62, 62,255) #3E3E3EFF rgba(62,62,62,1)
       120: ( 63, 63, 63,255) #3F3F3FFF rgba(63,63,63,1)
       121: ( 64, 64, 64,255) #404040FF rgba(64,64,64,1)
       122: ( 65, 65, 65,255) #414141FF rgba(65,65,65,1)
       123: ( 66, 66, 66,255) #424242FF rgba(66,66,66,1)
       124: ( 67, 67, 67,255) #434343FF rgba(67,67,67,1)
       125: ( 67, 67, 67,255) #434343FF rgba(67,67,67,1)
       126: ( 68, 68, 68,255) #444444FF rgba(68,68,68,1)
       127: ( 69, 69, 69,255) #454545FF rgba(69,69,69,1)
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 800x564+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Undefined
  Orientation: Undefined
  Properties:
    date:create: 2019-12-03T20:38:51+00:00
    date:modify: 2018-10-05T20:09:09+00:00
    dcm:AcquisitionDate: 20090407
    dcm:AcquisitionDateTime: 20090407122900.290000 
    dcm:AcquisitionTime: 122900.290000 
    dcm:BluePaletteColorLookupTableData: 
    dcm:BluePaletteColorLookupTableDescriptor: 
    dcm:GreenPaletteColorLookupTableData: 
    dcm:GreenPaletteColorLookupTableDescriptor: 
    dcm:ImageDate: 20090407
    dcm:ImageOrientation(Patient): 1.000000\0.000000\0.000000\0.000000\1.000000\0.000000 
    dcm:ImagePosition(Patient): 0.000000\0.000000\0.000000
    dcm:ImageTime: 122900.290000 
    dcm:ImageType: ORIGINAL\PRIMARY\ABDOMINAL
    dcm:Instance(formerlyImage)Number: 1 
    dcm:InstitutionName: HOSP. SAO FRANCISCO 
    dcm:LossyImageCompression: 00
    dcm:Manufacturer: Philips Medical Systems 
    dcm:Modality: US
    dcm:Patient'sID: 09-04-07-122438 
    dcm:Patient'sName: TICIANA BEZERRA DO NASCIMENTO^^^^ 
    dcm:PhotometricInterpretation: MONOCHROME2 
    dcm:PixelAspectRatio: 1\1 
    dcm:PixelSpacing: 0.50000000\0.50000000 
    dcm:RedPaletteColorLookupTableData: 
    dcm:RedPaletteColorLookupTableDescriptor: 
    dcm:RescaleIntercept: 0.000 
    dcm:RescaleSlope: 1.000 
    dcm:SequenceofUltrasoundRegions: ??
    dcm:SeriesInstanceUID: 1.3.46.670589.14.3000.101.180857.3.20090407122900.0000000010
    dcm:SeriesNumber: 1 
    dcm:SOPClassUID: 1.2.840.10008.5.1.4.1.1.6.1
    dcm:SOPInstanceUID: 1.2.276.0.7230010.3.1.4.1908265499.1824.1272939527.1
    dcm:SpecificCharacterSet: ISO_IR 100
    dcm:StudyDate: 20090407
    dcm:StudyID: 1860
    dcm:StudyInstanceUID: 1.3.46.670589.14.3000.101.180857.4.20090407122438.0000000012
    dcm:StudyTime: 122438.000000 
    dcm:WindowCenter: 125 
    dcm:WindowWidth: 250 
    signature: 974d2a11610523a56008a59998788bbc7fc1c231dfcc25a548d0d50d9413308b
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 454396B
  Number pixels: 451200
  Pixels per second: 24.4328MP
  User time: 0.030u
  Elapsed time: 0:01.018
  Version: ImageMagick 7.0.9-7 Q16 x86_64 2019-12-01
Is there any option I can use to convert those images?

TIA
julio

User avatar
fmw42
Posts: 25742
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Unable to convert DICOM image to PNG

Post by fmw42 » 2019-12-04T15:03:55-07:00

Please post a link to your DCOM file. Also show your exact Imagemagick command

jcarneiro
Posts: 2
Joined: 2019-12-04T14:01:45-07:00
Authentication code: 1152

Re: Unable to convert DICOM image to PNG

Post by jcarneiro » 2019-12-05T03:54:04-07:00

Here is the link to a couple DICOM images that fail: http://www.4ctv.com/Downloads/DICOM%20images.zip

And the command I'm using on Mac OS is:
convert image.dcm test.png
or conver image.dcm test.jpg

Pretty simple...

FYI, tried the same on Windows 10 and got the exact same result: Invalid color map index

User avatar
magick
Site Admin
Posts: 11093
Joined: 2003-05-31T11:32:55-07:00

Re: Unable to convert DICOM image to PNG

Post by magick » 2019-12-05T07:38:33-07:00

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.

Post Reply