I have been trying to create an image viewer for DICOM image. My program reads all the 8 bit colour and grayscale image almost correctly. But when I try to open a 16 bit image using the first 8 bits of the image, some parts are missing (pixels which uses 16 bit will be shown as dark instead of whilte). I don't really know how to use the window centre, window width, rescale slop and intercept. Please help me by giving the exact steps to convert 16 bit image to 8 bit image. Also I don't need to view the files which uses any compression technique to store the pixels. Thanks in advance.
About Rescale Slope/Intercept: It is a linear equation, so each pixel value is calculated by
<output pixel value> = <value from pixeldata attribute> * RescaleSlope + RescaleIntercept
This is the input to the windowing equation. The exact windowing equation is here.
About the inverted pixels: The attribute (0028,0103) is probably set to MONOCHROME1 which means: min=white, max=black (or "black bones" convention, i.e. the image contains the attenuation caused by the tissue between tube and detector). This is called the Polarity transformation and happens at the end of the pixel value transformation pipeline.
So your steps go:
apply rescale slope / intercept
apply windowing
- if PixelRepresentation==MONOCHROME1 -> invert the resulting lookup table
There is no a unique response.
You have to keep in mind that 16 bits images (bits stored) contains more information than images with 8 bits images. This information, in general, cannot be displayed all in the same time, you have to change the parameters used to display image.
In DICOM Images there are different DICOM tags that tells you how to interpretate data pixel. May be there are look-up table, and\or slope-intercept, and\or Window Width-Window Center tags. I think you have to take a look here
来源:https://stackoverflow.com/questions/40231080/convert-16-bit-grayscale-dicom-image-to-8-bit-the-correct-procedure