|
Window levels (center/width) have been an important part of the DICOM specification since its creation. If an image has a value range of 0 to 1000, but most of the pixels are close to 0, its ideal to be able to change the appearance of the image so the contrast between the low values is actually visible. This is done by altering the displayed value of each pixel, so if the screen range is 0 to 1000, the displayed pixels might be multiplied by 100, so the difference between an original pixel value of 1 and 2, would now be the difference between 100 and 200 on the screen. All that is a complex way of describing "brightness" and "contrast". The DICOM standard doesn't make it any easier however, and introduces two values that control the screen appearance of the image: window center and window width. This complex equation describes how an input pixel x is transformed into an output value with range [fmin,fmax], where the window center c and window width w must be >= 1.
In MIView, this is the function that calculates window levels:
CalculateWindowLevel(double width, double center, double value, double minVal, double maxVal)
{
double retVal;
if (width maxVal) retVal = maxVal;
if (retVal < minVal) retVal = minVal;
return retVal;
}
This is calculated on a range of values and stored as a lookup table which is fed into the pixel shader and which produces the final image. width, center, minVal, maxVal are all integers (even though they are passed into the function as doubles) and have a range specified by the range of image pixel values. Since 99% of medical images are stored as some size integer, the values of width and center will always be in the same range as the image. So if there was a 12-bit image, the range of pixels will be [0, 4095]. Window width/center will also be specified in this range. Some scaling will need to be done if the lookup table is a different size than the image range. |