DICOM black artifacts

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?".
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DICOM black artifacts

Post by magick »

We tried your compiler flags and still get expected results from the command you posted. We're clueless why its failing for you. Try ldd /usr/local/bin/convert and make sure the convert program is picking up the correct libMagickCore.so library. Note, ImageMagick 6.7.3-0 is now available.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

magick wrote:We tried your compiler flags and still get expected results from the command you posted. We're clueless why its failing for you. Try ldd /usr/local/bin/convert and make sure the convert program is picking up the correct libMagickCore.so library. Note, ImageMagick 6.7.3-0 is now available.
No change with ImageMagick 6.7.3-0 either :?

ldd looks fine to me :

Code: Select all

ldd /usr/bin/convert
        linux-vdso.so.1 =>  (0x00007fff3b3ff000)
        libMagickCore.so.5 => /usr/lib64/libMagickCore.so.5 (0x00007fa702408000)
        libMagickWand.so.5 => /usr/lib64/libMagickWand.so.5 (0x00007fa7020ea000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa701ecc000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fa701b28000)
        liblcms2.so.2 => /usr/lib64/liblcms2.so.2 (0x00007fa7018d6000)
        libtiff.so.5 => /usr/lib64/libtiff.so.5 (0x00007fa701661000)
        libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007fa7013c2000)
        libjpeg.so.8 => /usr/lib64/libjpeg.so.8 (0x00007fa701185000)
        liblqr-1.so.0 => /usr/lib64/liblqr-1.so.0 (0x00007fa700f71000)
        libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007fa700c4f000)
        libfftw3.so.3 => /usr/lib64/libfftw3.so.3 (0x00007fa7008d1000)
        libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007fa70069a000)
        libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007fa700486000)
        libSM.so.6 => /usr/lib64/libSM.so.6 (0x00007fa70027d000)
        libICE.so.6 => /usr/lib64/libICE.so.6 (0x00007fa700060000)
        libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007fa6ffd1e000)
        libXt.so.6 => /usr/lib64/libXt.so.6 (0x00007fa6ffab7000)
        liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007fa6ff894000)
        libbz2.so.1 => /lib64/libbz2.so.1 (0x00007fa6ff683000)
        libz.so.1 => /lib64/libz.so.1 (0x00007fa6ff46d000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fa6ff1e9000)
        libgomp.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libgomp.so.1 (0x00007fa6fefdb000)
        librt.so.1 => /lib64/librt.so.1 (0x00007fa6fedd2000)
        libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00007fa6febc8000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fa6fe9c4000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa7028a8000)
        libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x00007fa6fe79a000)
        libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fa6fe57c000)
        libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fa6fe378000)
        libXdmcp.so.6 => /usr/lib64/libXdmcp.so.6 (0x00007fa6fe172000)
Is it possible video drivers to mess with the conversion process somehow? I'm using nouveau video driver for my nvidia videocard. :?
Thank you!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DICOM black artifacts

Post by magick »

No, the video driver doesn't matter. We tried your image under Windows and Mac with 6.7.3-0 and it converted properly. Check that 'ls -lt /usr/lib64/libMagickCore.so.5' reports today as the create date.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

magick wrote:No, the video driver doesn't matter. We tried your image under Windows and Mac with 6.7.3-0 and it converted properly. Check that 'ls -lt /usr/lib64/libMagickCore.so.5' reports today as the create date.
Yes it's from today:

Code: Select all

ls -lt /usr/lib64/libMagickCore.so.5
lrwxrwxrwx 1 root root 22 окт 10 02:12 /usr/lib64/libMagickCore.so.5 -> libMagickCore.so.5.0.0
окт=oct

EDIT: The command 'display GEORGIEV_EMILIYAN.DCM' renders the same artifacts like convert command, that's why I'm thinking that something wrong is going on with the dicom part of imagemagick (on my system) or may be something related to X or mesa or kwin? Is it possible to be file system related (i'm using ext4)? :?

Thank you!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DICOM black artifacts

Post by magick »

The only option left is that ImageMagick is picking up the wrong DCM module. Add '-debug module' to your command line. Yours should return:

Opening module at path "/usr/lib64/ImageMagick-6.7.3/modules-Q16/coders/dcm.la"

and 'ls -lt /usr/lib64/ImageMagick-6.7.3/modules-Q16/coders/dcm.so' should return today's date. The last option is to build ImageMagick statically with
  • cd ImageMagick-6.7.3
    ./configure --disable-shared
    make
    make install
If that fails we have no other help to offer. We tried your image on 5 different computers and they all return the expected rendering of your DICOM image.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

Here is the debug output with dynamic linking :

Code: Select all

convert -debug module -define dcm:display-range=reset GEORGIEV_EMILIYAN.DCM -define png:color-type=4  -quality 100 -define png:compression-level=9 GEORGIEV_EMILIYAN.DCM1.png
zsh: correct 'GEORGIEV_EMILIYAN.DCM1.png' to 'GEORGIEV_EMILIYAN.DCM.png' [nyae]? n
2011-10-10T11:38:40+03:00 0:00.030 0.010u 6.7.3 Module convert[4746]: module.c/OpenModule/1264/Module
  Searching for module "DCM" using filename "dcm.la"
2011-10-10T11:38:40+03:00 0:00.030 0.010u 6.7.3 Module convert[4746]: module.c/GetMagickModulePath/565/Module
  Searching for coder module file "dcm.la" ...
2011-10-10T11:38:40+03:00 0:00.040 0.010u 6.7.3 Module convert[4746]: module.c/OpenModule/1273/Module
  Opening module at path "/usr/lib64/ImageMagick-6.7.3/modules-Q64/coders/dcm.la"
2011-10-10T11:38:40+03:00 0:00.070 0.010u 6.7.3 Module convert[4746]: module.c/OpenModule/1300/Module
  Method "RegisterDCMImage" in module "DCM" at address 0x7f74be70d300
2011-10-10T11:38:40+03:00 0:00.070 0.010u 6.7.3 Module convert[4746]: module.c/OpenModule/1314/Module
  Method "UnregisterDCMImage" in module "DCM" at address 0x7f74be70d380
2011-10-10T11:38:40+03:00 0:00.750 0.580u 6.7.3 Module convert[4746]: module.c/OpenModule/1264/Module
  Searching for module "PNG" using filename "png.la"
2011-10-10T11:38:40+03:00 0:00.750 0.580u 6.7.3 Module convert[4746]: module.c/GetMagickModulePath/565/Module
  Searching for coder module file "png.la" ...
2011-10-10T11:38:40+03:00 0:00.750 0.580u 6.7.3 Module convert[4746]: module.c/OpenModule/1273/Module
  Opening module at path "/usr/lib64/ImageMagick-6.7.3/modules-Q64/coders/png.la"
2011-10-10T11:38:40+03:00 0:00.770 0.590u 6.7.3 Module convert[4746]: module.c/OpenModule/1300/Module
  Method "RegisterPNGImage" in module "PNG" at address 0x7f74b51e97a0
2011-10-10T11:38:40+03:00 0:00.770 0.590u 6.7.3 Module convert[4746]: module.c/OpenModule/1314/Module
  Method "UnregisterPNGImage" in module "PNG" at address 0x7f74b51e9b80
It looks fine to me, no errors or warnings.

Here is the output with static linking (artifacts are still present):

Code: Select all

convert -debug module -define dcm:display-range=reset GEORGIEV_EMILIYAN.DCM -define png:color-type=4  -quality 100 -define png:compression-level=9 GEORGIEV_EMILIYAN.DCM1.png
zsh: correct 'GEORGIEV_EMILIYAN.DCM1.png' to 'GEORGIEV_EMILIYAN.DCM.png' [nyae]? n
2011-10-10T11:52:21+03:00 0:00.000 0.000u 6.7.3 Module convert[17842]: module.c/OpenModule/1264/Module
  Searching for module "DCM" using filename "dcm.la"
2011-10-10T11:52:21+03:00 0:00.000 0.000u 6.7.3 Module convert[17842]: module.c/GetMagickModulePath/565/Module
  Searching for coder module file "dcm.la" ...
2011-10-10T11:52:21+03:00 0:00.000 0.000u 6.7.3 Module convert[17842]: module.c/OpenModule/1273/Module
  Opening module at path "/usr/lib64/ImageMagick-6.7.3/modules-Q64/coders/dcm.la"
2011-10-10T11:52:21+03:00 0:00.010 0.000u 6.7.3 Module convert[17842]: module.c/OpenModule/1300/Module
  Method "RegisterDCMImage" in module "DCM" at address 0x7f9916ce5300
2011-10-10T11:52:21+03:00 0:00.010 0.000u 6.7.3 Module convert[17842]: module.c/OpenModule/1314/Module
  Method "UnregisterDCMImage" in module "DCM" at address 0x7f9916ce5380
2011-10-10T11:52:22+03:00 0:00.500 0.480u 6.7.3 Module convert[17842]: module.c/OpenModule/1264/Module
  Searching for module "PNG" using filename "png.la"
2011-10-10T11:52:22+03:00 0:00.500 0.480u 6.7.3 Module convert[17842]: module.c/GetMagickModulePath/565/Module
  Searching for coder module file "png.la" ...
2011-10-10T11:52:22+03:00 0:00.500 0.480u 6.7.3 Module convert[17842]: module.c/OpenModule/1273/Module
  Opening module at path "/usr/lib64/ImageMagick-6.7.3/modules-Q64/coders/png.la"
2011-10-10T11:52:22+03:00 0:00.500 0.480u 6.7.3 Module convert[17842]: module.c/OpenModule/1300/Module
  Method "RegisterPNGImage" in module "PNG" at address 0x7f990d7c17a0
2011-10-10T11:52:22+03:00 0:00.500 0.480u 6.7.3 Module convert[17842]: module.c/OpenModule/1314/Module
  Method "UnregisterPNGImage" in module "PNG" at address 0x7f990d7c1b80
I can't see any difference or problem in both outputs :?
I'll try today on my other PC and report (the main difference between both PCs are the processors)
Thank you for your help!
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

Well i think now that this problem is processor related.
On my intell machine everything is fine and correctly rendered!
Here are the details:

cpuinfo:

Code: Select all

processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 23
model name	: Intel(R) Core(TM)2 Duo CPU     T6600  @ 2.20GHz
stepping	: 10
cpu MHz		: 1200.000
cache size	: 2048 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dts
bogomips	: 4399.44
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 23
model name	: Intel(R) Core(TM)2 Duo CPU     T6600  @ 2.20GHz
stepping	: 10
cpu MHz		: 2200.000
cache size	: 2048 KB
physical id	: 0
siblings	: 2
core id		: 1
cpu cores	: 2
apicid		: 1
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dts
bogomips	: 4399.67
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

with the following imagemagick version:

Code: Select all

Version: ImageMagick 6.7.2-6 2011-09-20 Q32 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP  HDRI  


Here are the details of my AMD machine that produces the artifacts:

Code: Select all

processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 67
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 6000+
stepping        : 3
cpu MHz         : 1000.000
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good nopl extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips        : 2009.26
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc

processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 67
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 6000+
stepping        : 3
cpu MHz         : 1000.000
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good nopl extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips        : 2009.26
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc
with:

Code: Select all

display -version
Version: ImageMagick 6.7.3-0 2011-10-10 Q64 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP  HDRI  
My guess so far is that imagemagick's dicom module is using some processor instruction that is available in intell but not (or faulty) in amd :shock:
Thank you!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DICOM black artifacts

Post by magick »

We have an AMD dual processor (AMD Opteron Processor 844) and it produces the expected results. We're using gcc 4.6.1. We still have no idea why it fails for you.
rnbc
Posts: 109
Joined: 2010-04-11T18:27:46-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by rnbc »

Try executing under qemu with your OS of choice. That way others will be able to exactly reproduce your environment, even if you have to post the qemu image...
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

rnbc wrote:Try executing under qemu with your OS of choice. That way others will be able to exactly reproduce your environment, even if you have to post the qemu image...

Good idea ;)
Thank you!
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

magick wrote:We have an AMD dual processor (AMD Opteron Processor 844) and it produces the expected results. We're using gcc 4.6.1. We still have no idea why it fails for you.
You are absolutely correct,it's not the processor!
I forgot that i compiled imagemagic on intel machine with different options of '--with-quantum-depth='.
Yes this option is the source of all of my problems: different quantum depth + different size of the dicom file = artifacts with different severity ;)

A big dicom like this one (warning! It's 25MB image):
http://www.sendspace.com/file/xcjq54 + '--with-quantum-depth=64' the result is a black output
http://www.sendspace.com/file/xcjq54 + '--with-quantum-depth=32' the result is artifacts like mine
http://www.sendspace.com/file/xcjq54 + '--with-quantum-depth=8' the result is what i want (no artifcts)

A small dicom like this one ( 7.35MB )
http://www.sendspace.com/file/jc7l4g + '--with-quantum-depth=64' the result is artifacts like mine
http://www.sendspace.com/file/jc7l4g + '--with-quantum-depth=32' the result is what i want (no artifcts)
http://www.sendspace.com/file/jc7l4g + '--with-quantum-depth=8' the result is what i want (no artifcts)

You can see the pattern here 8)

"--with-quantum-depth" is messing badly with dicoms ;)
Thank you for the patience and help!
You guys are great :D
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DICOM black artifacts

Post by magick »

We tried quantum depths of 8, 16,32, and 64 and both your images converted properly without artifacts. DICOM uses floating point extensively. Perhaps there is a problem in the floating point conversion.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

magick wrote:We tried quantum depths of 8, 16,32, and 64 and both your images converted properly without artifacts. DICOM uses floating point extensively. Perhaps there is a problem in the floating point conversion.
May be, I don`t know. :?
At least now I can convert dicoms without artifacts using quantum depth of 8 8)
I hope you'll be able to get to the root of this problem.
If you need some assistance from me just let me know. I would be glad to help.
You are great team!
Thank you!
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

If you are aware what kernel options are responsible for floating point calculations I could check my kernel for them :idea:
Post Reply