DicomImage writeBMP() lost information

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Emma_cao
Posts: 13
Joined: Mon, 2016-12-05, 10:51

DicomImage writeBMP() lost information

#1 Post by Emma_cao »

My question is following:


string fileName = "E:\\test \\TG-18.dcm";
DcmFileFormat fileFormat;
OFCondition status = fileFormat.loadFile(fileName.c_str());

DicomImage* pDicomImage;
DcmDataset *pDataset = fileFormat.getDataset();
E_TransferSyntax xfer = pDataset->getOriginalXfer();
pDicomImage = new DicomImage(pDataset, xfer);
//pDicomImage->setMinMaxWindow();
//pDicomImage->setWindow(0);

pDicomImage->writeBMP("E:\\test \\1.bmp");


I use the upper code to save a 'dcm' file as a 'bmp' file. when I use the function setWindow() or setMinMaxWindow(),
I will got a bmp file with some informations lost. e.g.The pixels which value is 16 are lost.
I found that the LUT got in dimoopxt.h when calculating LUT entries is a little different.

Does somebody know why?
Best Wishes!

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DicomImage writeBMP() lost information

#2 Post by J. Riesmeier »

I use the upper code to save a 'dcm' file as a 'bmp' file. when I use the function setWindow() or setMinMaxWindow(),
I will got a bmp file with some informations lost. e.g.The pixels which value is 16 are lost.
I found that the LUT got in dimoopxt.h when calculating LUT entries is a little different.
I'm not sure what your question is. Maybe, the stored or automatically calculated VOI settings are not appropriate for this particular grayscale image (with more than 8 bits per pixel)?

Emma_cao
Posts: 13
Joined: Mon, 2016-12-05, 10:51

Re: DicomImage writeBMP() lost information

#3 Post by Emma_cao »

when I call the function setWinodw() in DicomImage, it will call function window() to calculating LUT entries. The value 16 corresponds to 0.996336... in the lookup table.
And then when I call function createWindowsDIB(), the data I got where the value is 0.9963336... will be 0.
Is that right?

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DicomImage writeBMP() lost information

#4 Post by J. Riesmeier »

I'm still not sure what your question is. If the input image is monochrome and has more than 8 bits per pixel, and the output image (in BMP format) supports only 256 shades of gray it should be obvious that some information is lost (grayscale values are downscaled, e.g. from 12 to 8 bits/pixel).

Emma_cao
Posts: 13
Joined: Mon, 2016-12-05, 10:51

Re: DicomImage writeBMP() lost information

#5 Post by Emma_cao »

sorry, I don't know how to describe it.

I setWindow(4096, 2048), then I got a LUT which has 4096 rows. And the corresponding value of 16 is 0.996336.
But in the output image the value 0.996336 is processed into 0 instead of 1.
Is that right?

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: DicomImage writeBMP() lost information

#6 Post by J. Riesmeier »

There is no rounding involved. Floating point numbers are truncated (to integers) if this was the question. For visualization purposes this makes no difference.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 1 guest