Page 1 of 1

Read & convert DICOM image

Posted: 2010-03-17T19:04:16-07:00
by filiabas
Hi all,

Is it possible to read and convert a DICOM to jpg? Although I have successfully installed latest version supporting the PHP interface, MagickReadImage() fails to read a dcm file (in other formats such as jpg, bmp function works fine).

imagick module version: 2.2.1-dev (ImageMagick 6.4.1 05/16/08 Q16)
MagickWand Extension Version: 1.0.5 (php-5.2.4_magickwand_q16_st.dll)
PHP Version: 5.2.13
Windows 7 x64

thank you very much
Filia

Re: Read & convert DICOM image

Posted: 2010-03-18T05:32:08-07:00
by magick
ImageMagick reads DICOM images. There have been enhancements and bug fixes to the DICOM reader since your release of ImageMagick. The current release is ImageMagick 6.6.0-5. If you post a URL to one of your images, we will download it and determine if the latest release can read it properly or if there is a bug in the DICOM reader.

Re: Read & convert DICOM image: Several tests included

Posted: 2010-03-18T10:20:17-07:00
by filiabas
Thanks for the quick prompt!

Configuration Update (phpinfo)
------------------------------------
ImageMagick version: ImageMagick 6.4.1 05/16/08 (php_imagick_st-Q16.dll is a previous version however MagicWand loads latest dll from the installed version. There is no down-loadable dll file for newest version to put in /ext PHP's dir.

MagickWand Extension Version: 1.0.5
ImageMagick support: enabled
ImageMagick version (Updated): ImageMagick 6.6.0-6 2010-03-15 Q16 (latest version, added php-5.2.4_magickwand_dyn.dll in php.ini). This update solved reading DICOM images issue in several cases.

Apache: Apache/2.2.15 (Win32) PHP/5.2.13
PHP: 5.2.13
OS: Windows 7 x64
------------------------------------

Tests
------------------------------------
The following tests utilised dcm examples from:
http://www.barre.nom.fr/medical/samples/

Simple PHP code used in all cases*:

$resource = NewMagickWand();
MagickReadImage( $resource, "the file");
MagickSetFormat($resource, 'JPG');
// just a simple manipulation
MagickSetImageCompression($resource, MW_JPEGCompression);
MagickSetImageCompressionQuality($resource, 100.0);
// browser output
header( 'Content-Type: image/jpg' );
MagickEchoImageBlob( $resource );


Cases
------
MagickReadImage( $resource, "CR-MONO1-10-chest.dcm"); //Result: OK
MagickReadImage( $resource, "CT-MONO2-16-ankle.dcm"); //Result: OK
MagickReadImage( $resource, "CT-MONO2-12-lomb-an2.dcm"); //Result: partially display
MagickReadImage( $resource, "MR-MONO2-12-an2.dcm"); //Result: OK
MagickReadImage( $resource, "MR-MONO2-12-shoulder.dcm"); //Result: Failure
MagickReadImage( $resource, "OT-PAL-8-face.dcm"); //Result: Failure
MagickReadImage( $resource, "US-RGB-8-esopecho.dcm"); //Result: partially display
MagickReadImage( $resource, "US-RGB-8-epicard.dcm"); //Result: Failure
MagickReadImage( $resource, "NM-MONO2-16-13x-heart.dcm"); //Result (series): OK (1st frame)

(*same test with MagickSetImageFormat)
MagickReadImage( $resource, "NM-MONO2-16-13x-heart.dcm"); // Result (series): OK (correct frame)
MagickSetImageIndex( $resource, 11 );
MagickSetImageFormat( $resource, 'GIF' );

MagickReadImage( $resource, "US-PAL-8-10x-echo.dcm"); //Result: Failure
MagickReadImage( $resource, "XA-MONO2-8-12x-catheter.dcm"); //Result: Failure

------------------------------------
Conclusion
It seems that MagickReadImage fails (halts Apache) in case of a dcm with compression.

I hope this input helps somehow!
Excellent work!
Filia

Re: Read & convert DICOM image II

Posted: 2010-03-18T11:12:20-07:00
by filiabas
PS 1: What types of compression (DICOM) are supported?

PS 2: MagickReadImage can read a DICOM from a URL (instead of reading from the filesystem)?

Thanks again,
Filia

Re: Read & convert DICOM image

Posted: 2010-03-18T11:15:52-07:00
by magick
A few of these are images are lossless JPEG and they can only be read if you build ImageMagick with the lossless patch to the JPEG delegate library. ImageMagick does fail for US-PAL-8-10x-echo when it shouldn't and we will have a patch to fix the problem within a few days. Thanks.