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?".
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

DICOM black artifacts

Post by kollin »

Hello,
Please help me to properly display and convert a dicom image with ImageMagick :?

The original .dcm image is here http://www.sendspace.com/file/jc7l4g

It's diplayed and converted by imagemagick like this:

https://picasaweb.google.com/lh/photo/S ... directlink

But it should be like this:

https://picasaweb.google.com/lh/photo/P ... directlink

How can i achieve it ?

OS: Gentoo Linux, amd64 using imagemagick-6.7.2.6


Thank you!
Best regards:
Kamen Dokov
rnbc
Posts: 109
Joined: 2010-04-11T18:27:46-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by rnbc »

I would say there is a overflow bug somewhere in the pipeline...

Maybe you can avoid it by using the HDRI enabled version of ImageMagick (involves a recompile) since it uses floating point and allows whiter than white colors.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

rnbc wrote:I would say there is a overflow bug somewhere in the pipeline...

Maybe you can avoid it by using the HDRI enabled version of ImageMagick (involves a recompile) since it uses floating point and allows whiter than white colors.
Thank you for the response!
But my imagemagick is already compiled with enabled hdri option :
emerge --info media-gfx/imagemagick
Portage 2.2.0_alpha39_p20 (default/linux/amd64/10.0/desktop, gcc-4.5.3, glibc-2.13-r4, 2.6.39.1-zen-00003-g6d6d304 x86_64)
=================================================================
System Settings
=================================================================
System uname: Linux-2.6.39.1-zen-00003-g6d6d304-x86_64-AMD_Athlon-tm-_64_X2_Dual_Core_Processor_6000+-with-gentoo-2.0.3
Timestamp of tree: Sun, 02 Oct 2011 09:00:01 +0000
ccache version 3.1.6 [enabled]
app-shells/bash: 4.2_p10
dev-java/java-config: 2.1.11-r3
dev-lang/python: 2.7.2-r3, 3.2.2
dev-util/ccache: 3.1.6
dev-util/cmake: 2.8.5-r2
dev-util/pkgconfig: 0.26
sys-apps/baselayout: 2.0.3
sys-apps/openrc: 0.9.3-r1
sys-apps/sandbox: 2.5
sys-devel/autoconf: 2.13, 2.68
sys-devel/automake: 1.9.6-r3, 1.10.3, 1.11.1-r1
sys-devel/binutils: 2.21.1-r1
sys-devel/gcc: 4.5.3-r1
sys-devel/gcc-config: 1.4.1-r1
sys-devel/libtool: 2.4-r3
sys-devel/make: 3.82-r3
sys-kernel/linux-headers: 2.6.39 (virtual/os-headers)
sys-libs/glibc: 2.13-r4
Repositories: gentoo repo_name-seti
Installed sets: @kde, @koffice
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64-sse3 -O2 -pipe -fomit-frame-pointer -ftree-vectorize -ftree-loop-linear"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/env.d /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config /usr/share/config/kdm/ /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0 /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=athlon64-sse3 -O2 -pipe -fomit-frame-pointer -ftree-vectorize -ftree-loop-linear -fvisibility-inlines-hidden"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs candy ccache distlocks ebuild-locks fixlafiles fixpackages news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://gentoo.osuosl.org http://mirrors.ludost.net/gentoo/ ftp://mirrors.ludost.net/gentoo/ http://gentoo.osuosl.org http://mirror.gentoo.no/ http://gentoo.ynet.sk/pub http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LANG="bg_BG.UTF-8"
LC_ALL="bg_BG.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--enable-new-dtags"
LINGUAS="en"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp/"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext X acl acpi alsa amd64 bash-completion bitmap-fonts bluray branding cairo cdr cli consolekit cracklib crypt cups dbus dri dvd dvdr dvdread encode esd evo exceptions fam fortran gcj gdbm gif gpm handbook html iconv ipv6 isdnlog jpeg kde4 ldap mad midi mikmod mmx mmxext mp3 mpeg mudflap multilib ncurses nls nptl nptlonly nsplugin ocamlopt ogg opengl openmp oss pam pcre pdf png policykit pppd pulseaudio python qt3support qt4 quicktime readline reflection sdl session spell spl sqlite sse sse2 sse3 ssl ssse3 svg tcpd threads tiff truetype truetype-fonts type1-fonts udev udisks unicode upower vorbis xcomposite xml xorg xv zeroconf zlib zsh-completion" ALSA_CARDS="hda-nvidia hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias asis auth_basic auth_digest authn_alias authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cern_meta charset_lite dav dav_fs dav_lock dbd deflate dir disk_cache dumpio env expires ext_filter file_cache filter headers ident imagemap include info log_config log_forensic logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http rewrite setenvif speling status substitute unique_id userdir usertrack version vhost_alias cgid cgi" APACHE2_MPMS="worker" CAMERAS="ptp2 canon" ELIBC="glibc" GPSD_PROTOCOLS="aivdm ashtech clientdebug earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 navcom nmea ntrip oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar timing tnt tripmate tsip ubx" INPUT_DEVICES="evdev" KERNEL="linux" LINGUAS="en" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nouveau"
Unset: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
Package Settings
=================================================================

media-gfx/imagemagick-6.7.2.6 was built with the following:
USE="X autotrace bzip2 corefonts cxx djvu fftw fontconfig fpx graphviz gs hdri jbig jpeg jpeg2k lcms lqr lzma (multilib) openexr openmp perl png q32 q64 q8 raw svg tiff truetype webp wmf xml zlib -opencl -static-libs"
I really want to use imagemagick for this kind of a job. It's powerful, quick, easy to use, well documented and offers great support and community.
I just can't figure this out alone :(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: DICOM black artifacts

Post by fmw42 »

I know very little about DICOM files. The one app (GraphicConverter) that could view your source image showed a lot of noise and was inverted.

Several tools such as Photoshop and GIMP could not open it and a couple, such as GIMP, gave messages about not able to handle 4096 bpp data.

Your image looks fine in IM display

display GEORGIEV_EMILIYAN.DCM

also

convert GEORGIEV_EMILIYAN.DCM GEORGIEV_EMILIYAN.PNG


And the PNG file displays fine also in IM

display GEORGIEV_EMILIYAN.PNG


I am using IM 6.7.2.9 Q16, but not HDRI, on Mac OSX tiger.


Have you tried converting to TIFF or some other format besides PNG to see if it is a PNG problem?

Have you upgraded your libpng?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DICOM black artifacts

Post by magick »

Upgrade to ImageMagick 6.7.2-9. It includes a DICOM patch that fixes the problem you reported.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

magick wrote:Upgrade to ImageMagick 6.7.2-9. It includes a DICOM patch that fixes the problem you reported.
fmw42 wrote:
I am using IM 6.7.2.9 Q16, but not HDRI, on Mac OSX tiger.


Have you tried converting to TIFF or some other format besides PNG to see if it is a PNG problem?

Have you upgraded your libpng?
I'll wait for few days till IM 6.7.2.9 comes to my distro and I'll report back here. ;)
I tried other formats but the output is the same, my hopes are concentrated on the new IM version 8)

Thanks guys, appreciated :D
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

fmw42 wrote:I know very little about DICOM files. The one app (GraphicConverter) that could view your source image showed a lot of noise and was inverted.

Several tools such as Photoshop and GIMP could not open it and a couple, such as GIMP, gave messages about not able to handle 4096 bpp data.
Don't even start with that!
I hate dicom files in the guts :-x This format is for medical CAT scans, MRI scans, medical 3d imaging etc. http://en.wikipedia.org/wiki/Dicom
Making simple dental images (2d, grayscale image) as dicom is like killing a fly with a hydrogen bomb.
PNG or TIFF could be sufficient. And on top of that each hardware/software manufacturer makes different dicoms (there is no guarantee that you'll be able to open it with different software), for example Kodak produces *. rvg dicom files :shock:

/end of the rant ;)
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

The new version makes no difference at all :cry:

Using :

Code: Select all

convert -version
Version: ImageMagick 6.7.2-9 2011-10-05 Q64 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP  HDRI  
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

Disabling HDRI does not make any difference also :?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DICOM black artifacts

Post by magick »

Post a URL to a rendering of your image in the PNG or JPEG format so we can compare what you think is the correct rendering to what ImageMagick produces. That will help us identify any bugs in the ImageMagick DICOM coder.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

magick wrote:Post a URL to a rendering of your image in the PNG or JPEG format so we can compare what you think is the correct rendering to what ImageMagick produces. That will help us identify any bugs in the ImageMagick DICOM coder.
This is how this image should look like: https://picasaweb.google.com/1120348732 ... 9512934754

This is how it is displayed and converted by imagemagick : https://picasaweb.google.com/1120348732 ... 3273174194

You can download both from picasa in .png format.

Thank you for your help!

Edit:
1. A direct link for how it should be: http://www.sendspace.com/file/a9b0ow
2.A direct link to how it is now: http://www.sendspace.com/file/y9ct3h
Last edited by kollin on 2011-10-09T08:04:18-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DICOM black artifacts

Post by magick »

We're using ImageMagick 6.7.2-10 and we get the correct results when converting your DICOM image.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

magick wrote:We're using ImageMagick 6.7.2-10 and we get the correct results when converting your DICOM image.
Strange!

Can you tell me please:

1.What command line options do you use for the conversion?
2.Which dependencies of imagemagick can cause such artifacts into the image ?

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

Re: DICOM black artifacts

Post by magick »

Make sure you are running the proper version of ImageMagick. The behavior your describe is what is expected to versions of ImageMagick prior to a recent patch we applied to fix the problem you posted. The conversion command was simple: convert image.dcm image.png. The DICOM coder does not rely on any dependencies. ImageMagick 6.3.0 will be released within a day or two if you want to try it but it should not be necessary ImageMagick 6.7.2-10 works for us.
kollin
Posts: 17
Joined: 2011-10-02T01:04:32-07:00
Authentication code: 8675308

Re: DICOM black artifacts

Post by kollin »

magick wrote:Make sure you are running the proper version of ImageMagick. The behavior your describe is what is expected to versions of ImageMagick prior to a recent patch we applied to fix the problem you posted. The conversion command was simple: convert image.dcm image.png. The DICOM coder does not rely on any dependencies. ImageMagick 6.3.0 will be released within a day or two if you want to try it but it should not be necessary ImageMagick 6.7.2-10 works for us.
I'm sorry but the 6.7.2-10 version does not change anything for me :(

http://www.sendspace.com/file/lpsgdp This image is a result of the following command:

Code: Select all

convert -define dcm:display-range=reset GEORGIEV_EMILIYAN.DCM -define png:color-type=4  -quality 100 -define png:compression-level=9 GEORGIEV_EMILIYAN.DCM1.png
http://www.sendspace.com/file/eow6i3 And this is a result of the following command:

Code: Select all

convert GEORGIEV_EMILIYAN.DCM GEORGIEV_EMILIYAN.DCM2.png

I'm using with both comands:

Code: Select all

convert -version
Version: ImageMagick 6.7.2-10 2011-10-10 Q64 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP  HDRI  

I really don't know what is going on :shock:
Is it possible some cflags or ldflags to mess things up during compile time?
I'm using the following flags:

Code: Select all

CFLAGS="-march=athlon64-sse3 -O2 -pipe -fomit-frame-pointer -ftree-vectorize -ftree-loop-linear"
CXXFLAGS="-march=athlon64-sse3 -O2 -pipe -fomit-frame-pointer -ftree-vectorize -ftree-loop-linear -fvisibility-inlines-hidden"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--enable-new-dtags"
Post Reply