tool img2dcm not useful for gray level image with BMP format

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
winstondcm
Posts: 31
Joined: Wed, 2010-03-24, 17:14

tool img2dcm not useful for gray level image with BMP format

#1 Post by winstondcm »

hi, dcmtk team:

i found img2dcm tool can not use to convert graylevel BMP image to DCM, right?

i tried today, it shows failure:
img2dcm -i BMP -d gray8bit.bmp dcmfromgraybmp.dcm
and i get: (with -debug chosen)
D: I2DBmpSource: Plugin instantiated
I: img2dcm: Instantiated input plugin: BMP
D: I2DOutputPlugSC: Output plugin for Secondary Capture initialized
I: img2dcm: Instantiatiated output plugin: Secondary Capture Image SOP Class
I: img2dcm: Starting image conversion
D: Image2Dcm: Starting conversion of file: gray8bit.bmp
D: Image2Dcm: Generate and insert new UIDs if necessary
D: I2DBmpSource: Importing BMP pixel data
D: I2DBmpSource: Opening BMP file: gray8bit.bmp
D: I2DBmpSource: BMP data at file offset: 1078
D: I2DBmpSource: BMP bpp: 8
D: I2DBmpSource: BMP width: 512
D: I2DBmpSource: BMP height: 512
D: I2DBmpSource: BMP stored as top down: No
D: I2DBmpSource: Starting to read bitmap data
D: I2DBmpSource: Closing BMP file and cleaning up memory
D: Freeing memory
F: Error converting file: unsupported BMP file - wrong bpp
so , i have to write the convert myself? (pick up the raw data from BMP and create a dcm?)

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

#2 Post by Uli Schlachter »

img2dcm currently can only handle color BMP files (no color palette, 24 BPP), this is correct.
You could convert your graylevel BMP into such an image first, but you'd get a color DCM object, too.

Please note that AFAIK there are no "real" graylevel BMP images, there are always some kind of colors involved.

winstondcm
Posts: 31
Joined: Wed, 2010-03-24, 17:14

thank you

#3 Post by winstondcm »

thank you, sir.

by "no real graylevel BMP " in dicom, you mean, the LUT is linear, so the image displayed is gray, "there is always color involved", refers to LUT?

thank you very much.

winston.

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

#4 Post by Uli Schlachter »

I'm not hundred percent sure, but I think a greylevel BMP is a color BMP in reality which just happens to use only gray-ish colors. So if one just took that and converted it into DICOM, one would still have a color image which only uses gray levels.
The image wouldn't have a LUT at all, but instead the default values for RescaleSlope and RescaleIntercept (which is basically a linear LUT, yeah).

As for converting your image to DICOM, the best suggestion I have currently would be convert the BMP to JPEG and feed that one to img2dcm.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#5 Post by Jörg Riesmeier »

There's also a palette color BMP format where the look-up table contains gray values only (i.e. identical values for the RGB components). Btw, this is also the format that is used as an output format for dcm2pnm with the following option:

Code: Select all

+obp    --write-8-bit-bmp     write 8-bit palette BMP (monochrome only)

winstondcm
Posts: 31
Joined: Wed, 2010-03-24, 17:14

#6 Post by winstondcm »

thank you, jorg.

maybe you meant, from a dicom file converting to a grayscale 8 bit BMP? yes, i know this option

but, what i am trying to do is the reverse, converting a 8 bit grayscale BMP to a dicom file, img2dcm refused..

i have to load the data from bmp, and create a dicom from raw data..and successful... so, in my program, i have to judge if the incoming file is true color or grayscale.. and then apply img2dcm or another program. a little bothersome, though.

thank you .

winston.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#7 Post by Jörg Riesmeier »

maybe you meant, from a dicom file converting to a grayscale 8 bit BMP?
No, I was referring to the BMP format for grayscale images which is in fact a palette color image with 8 bits per pixel and a look-up table with 256 entries. So, as far as I know there is no such thing as an "8-bit grayscale BMP format".

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest