very bad bug in 6.6.0-6 with DICOM

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
L F

very bad bug in 6.6.0-6 with DICOM

Post by L F »

Hello, I've ran into a bad thing in ImageMagick. Version is 6.6.0-6, OS - Ubuntu 9.10.
I use:
convert <dicom-file> -resize 64x64 <jpeg file>
to transform DICOM-file into jpeg, and it sticks. DICOM is MONOCHROME2, 4-bytes per pixel.
The same happens if to use Image "read"/"write" from magick++ for the dicom-file.

But the most bad is that the conversion it not only hangs but allocates more and more memory continiously.

I checked the same file on Fedora 9+ImageMagick 5.5.7 and it works, creates black thumbnail instead of a picture, but doesn't fail or stick.

Question: am I doing something wrong or the latest IM versions don't support such type of DICOM-files ?

Thanks in advance.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: very bad bug in 6.6.0-6 with DICOM

Post by fmw42 »

I downloaded your file. I know nothing about dcm images. I checked my system (IM 6.6.1-0 beta) and

convert -list format

shows
DCM* DCM r--

so supposedly read only. I then tried

identify -verbose 111.dcm

identify: memory allocation failed `111.dcm' @ error/dcm.c/ReadDCMImage/3590.


I am not sure if I need some delegate library or not.

Might your file be corrupt?

Opening it in GraphicsConverter shows a completely black image. Photoshop will not open it.

Only ImageJ seems to be able to open it successfully and show something reasonable --- basically a black image with a fuzzy white center area.
Last edited by fmw42 on 2010-03-31T11:59:27-07:00, edited 3 times in total.
L F

Re: very bad bug in 6.6.0-6 with DICOM

Post by L F »

No, you don't need a delegate library, it was ever supported in ImageMagick. And the file is not corrupted, viewers open it, you may use ImageJ for example.

Identify from IM 5.5.7 gives:
./111.dcm DCM 211x179+0+0 PseudoClass 65536c 16-bit 153.3kb 0.010u 0:01

Yes, your picture in ImageJ is correct.
Last edited by L F on 2010-03-31T12:01:12-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: very bad bug in 6.6.0-6 with DICOM

Post by fmw42 »

Yes, ImageJ does work. And I get from IM the same error on a simple identify

identify 111.dcm
identify: memory allocation failed `111.dcm' @ error/dcm.c/ReadDCMImage/3590.
L F

Re: very bad bug in 6.6.0-6 with DICOM

Post by L F »

I've compared different IM versions and Fedora vs Ubuntu and result is: the latest (at least 6.5 and 6.6) IMs doesn't read DICOM files with 4 bytes per pixel. The only IM 5.5.7 does it, maybe not too correctly but without errors and sticking.

Question: is it possible to define depth somehow before reading into Image from a file as:

fileIn.read(file_name);

if it can help with the above file?

Thanks.
L F

Re: very bad bug in 6.6.0-6 with DICOM

Post by L F »

Possibly this very code in ImageMagick causes the problem: coders/dcm.c :
...
Quantum *scale
...
if (image->depth != (1UL*MAGICKCORE_QUANTUM_DEPTH))
.....
length=(size_t) (GetQuantumRange(image->depth)+1);
scale=(Quantum *) AcquireQuantumMemory(length,sizeof(*scale)); !!!!!!!!!!
if (scale == (Quantum *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
......
Post Reply