Page 1 of 1

Reading 16-bit DICOM image does not work any more

Posted: 2012-07-26T11:03:06-07:00
by paavo256
It appears there is some version or platform difference in how ImageMagick handles 16-bit grayscale DICOM images. Our code has not changed; on Linux and Windows with ImageMagick 6.4.3 we get a 16-bit grayscale result, wherease on Mac with ImageMagick 6.7.8 we get an RGB (3x8bits) image (with apparently identic color channels). This means serious loss in the precision (16 bits->8 bits). Is it possible to somehow force the 16-bit grayscale output? Our code is using Magick++ and looks about like this:

Code: Select all

	
	Magick::Image image;
	image.read(filename.c_str());
	Magick::ImageType t = image.type();
	if (t==Magick::GrayscaleType || t==Magick::GrayscaleMatteType) {
		switch(image.depth()) {
			case 8:
				image.write(0, 0, w, h, "I", Magick::CharPixel, buffer);
				break;
			default:
				image.write(0, 0, w, h, "I", Magick::ShortPixel, buffer);
				break;
		}
	} else {
		image.write(0, 0, w, h, "BGR", Magick::CharPixel, buffer);
	}
TIA

Re: Reading 16-bit DICOM image does not work any more

Posted: 2012-07-26T15:01:48-07:00
by fmw42
I don't know much about DICOM or the changes you are seeing. Lots has changed since your first version. But you can try adding the command line equivalents of -depth 16 -type grayscale. What output image format are going to ? Sorry I do not know any API or the equivalent for them.

Re: Reading 16-bit DICOM image does not work any more

Posted: 2012-07-26T15:30:08-07:00
by paavo256
fmw42 wrote:But you can try adding the command line equivalents of -depth 16 -type grayscale.
My problem is that this is some very general library code which has no idea what image it is reading, it might well be some color jpg or dicom or whatever. To be honest, I have no independent knowledge about the type of this particular DICOM image, I am just relying on the fact that the former ImageMagick repors the read-in image type as Magick::GrayscaleType and bit depth as 12.

Re: Reading 16-bit DICOM image does not work any more

Posted: 2012-07-26T18:03:01-07:00
by fmw42
Perhaps you should provide a link to your DICOM image so that the IM developers can test with it.

Re: Reading 16-bit DICOM image does not work any more

Posted: 2012-07-26T23:03:16-07:00
by paavo256

Re: Reading 16-bit DICOM image does not work any more

Posted: 2012-07-27T06:29:04-07:00
by magick
We can reproduce the problem you posted and have a patch. Look for it in ImageMagick 6.7.8-7 within a few days. Thanks.