Search code examples
codecdicommedicaljpeg2000

Can DICOM pixel data compression decompression mess with window center and window width


I am viewing Computerized Tomography ( CT) DICOM images. These were originally uncompressed DICOM images. I have lossless J2K compressed form of these DICOM images: Transfer syntax = 1.2.840.10008.1.2.4.90 (JPEG-2K Lossless). When I uncompress these DICOM images back: Transfer Syntax =1.2.840.10008.1.2.1 (Little Endian Explicit) and view both the compressed and uncompressed DICOM images side by side in a DICOM viewer then I observe that - The compressed and uncompressed images need a different "window level " for viewing ( "Window level" = Combination of window center' = WC = Brightness and "window Width" = WW = Contrast) - The DICOM header does not seem to be different - The compressed image can be viewed at the industry standard/preset level for the kind of image - but the uncompressed image does NOT look good at that level

So questions

  1. Could this change in level ( window center and window width) be attributed to a problem with my codec. Like my codec is messing with pixel data because it treats it incorrectly ?
  2. Is there a way I could correct this problem by adjusting fields in DICOM header ?

I checked out the Post on Window width and center calculation of Dicom Image. While that post tells me that rescale intercept and slope are applied to transform the pixel values of the image into values that are meaningful to the application I am trying to figure how I can correlate with

  • what I see visually ( relation between the original and adjusted window center and window width)
  • Is there a way I can correlate the pixel values in a programmatic way to arrive at a value for wc, ww, scale intercept slope ?

I also checked out (Correct Pixel Processing Logic for DICOM JPEG(RGB) for Applying Window Width and Level Filter) - however that seems to relate to rendering of image. My question is related to adjusting DICOM header ( wc? ww? scale intercept ? slope ? ) to enable viewers to render it correctly. Looking at the DICOM pixel data can I arrive at appropriate level for these group 28 elements based on pixel values in the pixel data element . Is there a known function to compute something of this sort ?

my image is monochrome

Thanks much

Yogesh Devi


Solution

  • If you know the real-world range, you should be able to calculate the scale and intercept to fix in the header, leaving everything else like the window levels the same. See below for the calculations...

    From the good image, if you find the range of the pre-scaled data, it might look like this:

    min1 = 100
    max1 = 1900
    

    Using the header scale/intercept info...

    scale1 = 5
    intercept1 = 500
    

    ... you can then convert it into real-world, meaningful values:

    (min1 * scale1) + intercept1 = real-min
    (max1 * scale1) + intercept1 = real-max
    
    real-min = 1000
    real-max = 10000
    real-range = 9000
    

    In the bad image, you need to ignore the header and just find the pre-scaled data range. For example:

    min2 = -100
    max2 = 17900
    range2 = 18000
    

    Now calculate the scale and intercept using the real-world range:

    scale2 = (real-range / range2) = 0.5
    intercept2 = real-max - (max2 * scale2) = 1050
    

    Applying them, you can test that you get the right real-world values:

    (min2 * scale2) + intercept2 = (-100 * 0.5) + 1050 = 1000 = real-min
    (max2 * scale2) + intercept2 = (17900 * 0.5) + 1050 = 10000 = real-max