Correct Pixel Processing Logic for DICOM JPEG(RGB) for Applying Window Width and Level Filter

本秂侑毒 提交于 2019-12-09 07:44:53

问题


I am trying to apply widow width and level filter to JPEG Image which I extracted from DICOM file.

Here is logic I use to process Each Channel of RGB Image fore example I manipulate Red Channel Like below code in Render-Script in android

Example code where I shown how I manipulate Red Channel of Image. (I do same for Green and Blue Channels)

It does manipulate the JPEG Image Widow Width and Level but not sure if its correct way to manipulate DICOM JPEGS if some body know correct way to manipulate RGB JPEGS Window Width and Level with correct pixel processing math please help me as Its result some what (20%) differs from Windows Based DicomViewers ( I know Window Level and Width is for Monochrome Images Only but Some DicomViewers Such as "ShowCase" they do apply such filters on RGB )

    displayMin = (windowLevel- windowWidth/2);
    displayMax = (windowLevel+ windowWidth/2);

    /*Manipulate Red Channel */
    if(current.r < displayMin)
    {
      current.r = 0;
    }
    else if(current.r > displayMax)
    {
       current.r = 1;
    } 

回答1:


Your current approach simply truncates the input data to fit the window, which can certainly be useful. However, it doesn't really let you see see the benefit of the window/level, particularly on images greater than 8bpp, because it doesn't enhance any of the details.

You'd typically want to remap the windowed input range (displayMin to displayMax) onto the output range (0 to 1) in some way. I don't think there is a definitive 'correct' approach, although here's a simple linear mapping that I find useful:

if (current.r <= displayMin || displayMin == displayMax)
{
    current.r = 0;
}
else if (current.r >= displayMax)
{
    current.r = 1;
}
else
{
    current.r = (current.r - displayMin) / (displayMax - displayMin);
}

What that's doing is simply taking your restricted window, and expanding it to use the entire colour-space. You can think of it like zooming-in on the details.

(The displayMin == displayMax condition is simply guarding against division-by-zero.)



来源:https://stackoverflow.com/questions/19904504/correct-pixel-processing-logic-for-dicom-jpegrgb-for-applying-window-width-and

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