rescale slope and rescale intercept

笑着哭i 提交于 2019-11-30 09:05:09
Paolo Brandoli

The rescale slope and rescale intercept allow to transform the pixel values to HU or other units, as specified in the tag 0028,1054.

For CT images, the unit should be HU (Hounsfield) and the default value is indeed HU when the tag 0028,1054 is not present. However, the tag may be present and may specify a different unit (OD=optical density, US=unspecified).

The rescale slope and intercept are determined by the manufacturer of the hardware.

If the transformation from original pixel values to Hounsfield or Optical density is not linear, then a LUT is applied.

Check the part 3 of the standard C.11 for more detailed information, and also this answer Window width and center calculation of DICOM image

This is my implementation:

def window_ct(dcm, w, c, ymin, ymax):
    """Windows a CT slice.
    http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.11.2.html

    Args:
        dcm (pydicom.dataset.FileDataset):
        w: Window Width parameter.
        c: Window Center parameter.
        ymin: Minimum output value.
        ymax: Maximum output value.

    Returns:
        Windowed slice.
    """
    # convert to HU
    b = dcm.RescaleIntercept
    m = dcm.RescaleSlope
    x = m * dcm.pixel_array + b

    # windowing C.11.2.1.2.1 Default LINEAR Function
    #
    y = np.zeros_like(x)
    y[x <= (c - 0.5 - (w - 1) / 2)] = ymin
    y[x > (c - 0.5 + (w - 1) / 2)] = ymax
    y[(x > (c - 0.5 - (w - 1) / 2)) & (x <= (c - 0.5 + (w - 1) / 2))] = \
        ((x[(x > (c - 0.5 - (w - 1) / 2)) & (x <= (c - 0.5 + (w - 1) / 2))] - (c - 0.5)) / (w - 1) + 0.5) * (
                ymax - ymin) + ymin

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