How to downgrade 16 bit depth gray scale to 8 bit depth image (rgb 24) [closed]

大兔子大兔子 提交于 2019-12-08 15:32:07

问题


So I am working in a WPF project.

I have two DICOM Images(X-ray(16 bits gray scale) Image and an Optical(24 bit RGB) Image).

What I want

I wanna blend the two image one on the another by changing opacity. Its like increase or decrease opacity between the two images.

If I wanna blend these two images, what I wanted to do is downgrade the x-ray image to 8 bits gray scale. So the it will match the 24 bit optical image while blending.

My Problem

How can I downgrade a 16 bits gray scale DICOM image to 8 bits depth (24 bits RGB).

What I have tried

I have tried to downgrade the image using PixelFormats.

stride = width * 4;
size = height * stride;
bitmapSource = BitmapImage.Create(width, height, 96, 96, System.Windows.Media.PixelFormats.Gray8, null, bitmapBuffer, stride);

But if I tried to use the above code the resulting image looks grainy and has some losses. What can I do to maintain the quality of the image and downgrade it at the same time.

Please help me. I am a newbie to image processing and DICOM domain.


回答1:


I do not see a good chance to use any Microsoft API for that. There are lots of attributes in the DICOM header that you should consider:

  • (0028,0101) Bits Stored tells you the real number of bits used by the pixel data. Make sure to mask out unused bits - they might contain random bits
  • (0028,0004) Photometric Interpretation tells you whether you need to invert the image prior to downscaling (MONOCHROME1 -> Identity, MONOCHROME2 -> Invert)
  • (0028,3000) Modality LUT Sequence might specify a non-linear transformation of the pixel data that should be considered
  • (0028,0103) Pixel Representation tells whether the binary values of pixels are to be interpreted as unsigned integers or as 2s complement signed integers

The next question is: What is the target of the downscaling

  • The raw pixel data as it is - then you are fine to just rescale the pixels (potentially mapped by the Modality LUT) to the new range.
  • The image as it should be perceived by the doctor - then further attributes need to be taken into account

In the latter case the following transformations apply

  • Rescale Slope / Intercept (0028,1053) / (0028,1052) define a liniear transformation of the pixel data to the value range measured by the device. It is uncommon but not forbidden that the pixel values exceed 16 bit after the transformation
  • Window Center / Width (0028,1050) / (0028,1051) define the range of pixel data which are to be mapped to 8-bit. More than one Window/Level set may be present, so the difficulty will be to choose the appropriate one.

EDIT: After it was clarified that this functionality is to be incorporated in an interactive UI, I recommend to: Read the pixel data to a "native" format by combining the attributes which define how the pixel data is to be interpreted (see above). You obtain an intermediate representation from this step in which the pixel data is represented as measured values from the device in 32/64 bit unsigned integer format. Then choose the first Window/Center set from the DICOM header to define the downscaling to 8 bit (see here). But allow the user to select other Window/Center sets from the header if present and allow her to adjust it manually.



来源:https://stackoverflow.com/questions/49426431/how-to-downgrade-16-bit-depth-gray-scale-to-8-bit-depth-image-rgb-24

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!