3

I am trying to develop a dicom image viewer. I have successfully decoded the image buffer. I store all the image pixel values in an unsigned char buffer in C++.

Now, when I display the image it is working fine for images with pixel representation (0028,0103) =0. Could someone show me how to apply this signed conversion into these decoded buffer. I don't know how to convert this signed bits into unsigned bit (I think the usual conversion using typecast doesn't work well). Please post the replay for 16 bit image, that is what I really need now.

I am trying to create a viewer from scratch, which simply puts the image in screen. I have successfully completed the decoding and displaying of the dicom image. But when I try to open an image which has a pixel representation (tag 0028,0103) =1, the image is not showing correctly. The conversion from 16 bit to 8 bit is done along with applying window level and width (value found inside the dicom image), the conversion is simply linear.

  • Please provide a bit more detail on what you want to achieve, because your question currently needs much more answers than you would probably expect. Especially it is important to know how you want to control the loss of information when downscaling 16 -> 8 bit. Do you apply windowing? Or do you just downscale the raw pixel data? Is your viewer going to support functionality beyond "display-as-is", e.g. adjusting brightness/contrast? Are you using a DICOM library or do you really build DICOM file reading from scratch? – Markus Sabin Nov 02 '16 at 14:33
  • Duplicate of http://stackoverflow.com/questions/40231080/convert-16-bit-grayscale-dicom-image-to-8-bit-the-correct-procedure ? – Severin Pappadeux Nov 02 '16 at 15:15
  • Thank you for your time, I have added the details in the question. – user6848035 Nov 03 '16 at 03:54
  • http://stackoverflow.com/questions/40231080/convert-16-bit-grayscale-dicom-image-to-8-bit-the-correct-procedure this question is about converting the 16 bit image to 8 bit image which i have done successfully. Now i need to know know how to apply sign bit in a dicom image – user6848035 Nov 03 '16 at 05:10
  • There're no *signed bits* or *unsigned bits*. There are only bits and *signed type* and *unsigned type* – phuclv Nov 03 '16 at 07:40

1 Answers1

0

Make sure to correctly read the pixel data into a signed short array by taking the TransferSyntax (endianess) into account. Then apply the windowing equation from the DICOM Standard. In setting ymin=0, ymax = 255 rescaling to 8 bit is achieved.

In general, there is more to take into account about handling DICOM pixel data:

  • Photometric Interpretation
  • Bits Stored, High Bit
  • Modality LUT (Rescale Slope/Intercept or a lookup table stored in the DICOM header)

I am assuming that Photometric Interpretation is MONOCRHOME2, High Bit = Bits Stored - 1, Modality LUT is Identity transformation (Slope = 1, Intercept = 0).

Other SO posts dealing with this topic:

Converting Pixel Data to 8 bit

Pixel Data Interpretation

Community
  • 1
  • 1
Markus Sabin
  • 3,916
  • 14
  • 32