rescale slope and rescale intercept

前端 未结 2 1970
孤街浪徒
孤街浪徒 2020-12-28 18:04

I have few questions about the rescale slope and rescale intercept in CT DICOM:

  1. Are they us
2条回答
  •  离开以前
    2020-12-28 18:31

    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
    

提交回复
热议问题