“Helping educational programs make digital radiography easy to understand.”

Rescaling, Gradation, and Windowing: Slow and Easy

Quinn B. Carroll, MEd, RT

 

 

 

From the Spatial Domain to the Intensity Domain and Back

Maintaining the Image Matrix:

Rescaling, Gradation Processing, and Windowing are all intensity operations. Intensity operations affect each pixel throughout the image that holds a particular initial pixel value, regardless of where it is located within the image matrix

How can the same change be made to all pixels with a particular value, when they are in different locations?

This requires an overview of image processing “domains”

Three General Approaches to Processing any Digital Image:

OPTIONAL: Examples:

SPATIAL OPERATIONS

Examples:   -Point, area, and global processing

-Kernels

 

INTENSITY OPERATIONS

Examples:   -Histogram construction & analysis

-Rescaling (Processing)

-Gradation processing (LUTs)

-Windowing

 

FREQUENCY OPERATIONS

Examples:   -Edge enhancement

-Smoothing

 

Image Domains:

In the SPATIAL domain:

Pixels are sorted by their location

 

INTENSITY OPERATIONS

Pixels are sorted by their pixel values

(gray levels)

 

FREQUENCY OPERATIONS

Objects (details) are sorted by their size

 

Sorting an image by location results in a MATRIX

Sorting an image by intensity results in a HISTOGRAM

Sorting an image by size of objects results in a FREQUENCY DISTRIBUTION

Maintaining the Image Matrix:

All intensity operations are performed on the “bins” (computer files) holding a simple pixel count for each density value. They affect each pixel throughout the image which holds a particular initial value, regardless of where it is located within the image matrix

How can these processed values be re-aligned “in space” across the area of the image matrix to reconstruct the image on a display monitor screen?

i.e., How does the computer transition between domains?

Before any processing occurs, the computer logs the location of every pixel value by its matrix     designation

This information is stored until the histogram is 1. constructed, 2. analyzed, 3. rescaled and 4. gradation processed

The result is a modified final histogram when the final displayed image is reconstructed

Final values from each “bin” (or bar in the modified histogram) are then assigned to all pixels from the matrix that held those original values

In this way, a “map” is maintained of where each pixel value belongs throughout histogram processing

Demo: Transitioning between processing domains

 

OPTIONAL: How the Histogram is Analyzed

Identifying Landmarks:

The computer scans the data inward  from both the left and the right ends of the histogram

From each end, the first bin containing non-zero pixel values is identified

Here, the 1st point at the left is SMIN

S MIN must be identified from within the data curve (i.e. represent anatomy)

S MAX represents the darkest density within the body part

S AVE  = The average density within the anatomy, is used to calculate the exposure indicator

A simpler method subtracts the number of pixels in each bin from the bin to the right

Example Using Subtraction Method:

SMAX can be identified as the second point in the data, from right to left, that negative results occur (where the curve starts to rise again)

To identify landmarks in the data, most manufacturers use threshold algorithms that only begin storing values when a certain number of pixels holding these values is reached.

Types of Histogram Analysis:

At the control console, selecting the procedure algorithm assigns the type of histogram analysis to be used

 

For each radiographic projection, an “ideal” histogram is generated by a permanent LUT stored in the computer – All acquired histograms for that view are compared with this reference histogram

 

Each type of histogram analysis “expects” a particular shape and number of lobes for the acquired histogram. These must match to avoid errors in rescaling and the EI.

Type I: two lobes       Type 2: one Lobe     Type 3: three lobes

Type I: The computer algorithm “expects” a direct exposure area (background) to be present, creating a “spike” to the right in the acquired histogram

Type II: “Expects” no direct exposure area and no unusual light areas (no “tail spike” in the histogram)

 

Type III: “Expects” a large area of light exposure due to the presence of barium or other metal (lead shield or prosthesis), creating a “spike” to the left in the acquired histogram

 

These expectations determine whether the computer algorithms will search for an SMIN point, an SMAX point, or both, in the acquired histogram

All data outside of the two graph points SMIN  and SMAX  must eliminated from the calculations used to produce the final image without processing errors

When the type of histogram analysis is mismatched to the actual shape of the acquired histogram, analysis errors will occur

Values of Interest (VOI):

To accentuate particular anatomy, a computer algorithm first selects a particular range of  densities from the image to operate on, called the values of interest (VOI). Above, A accentuates bone tissue, B accentuates soft tissue

Histogram Analysis Errors:

Can occur from several causes:

From segmentation or exposure field recognition errors

When the type of histogram analysis applied is mismatched to the actual histogram acquired

When the acquired histogram attains a bizarre, unexpected shape

 

The acquired image histogram attains a bizarre, unexpected shape from the image data when:

Multiple exposure errors combine

Very extreme exposure conditions exist

 

Example: Error form Unexpected Histogram Shape:

A lead apron and a large radiopaque prosthesis may result in two “spikes” at the left in the data

The computer may locate SMIN between these two spikes, too far to the left, include data from the prosthesis in the VOI with SAVE too far left, and overcorrect toward a dark image

 

Modern digital processing is becoming more robust and resistant to errors

When errors do occur, the results are unpredictable – Image can be light or dark

 

How RESCALING (Processing) Always Gets It Right

Summary of Default Digital Processing:  “Rescaling” = “Processing”

A “raw” digital image directly from the image receptor appears “washed-out,” with low contrast

Re-mapping the brightness and gray scale of the digital image so that it appears like a “normal” or conventional   radiograph

Rescaling  is the step that “automatically” corrects brightness for each image

Rescaling is simply a process of algebraically “re-labeling” incoming data

A permanent look-up table of Q values is stored in the computer. Here:

QMIN is always  output at 511

-Q2  as 512

-Q3  as 513 …

-QMAX as 1534

The Q values in this permanent look-up table represent the “ideal” histogram for the anatomical procedure

For the acquired  image histogram …

“Bins” of data from the acquired image to be used for rescaling are designated as S values

Here, the “bins” of data between SMIN and SMAX  are designated as S2, S3, S4 and so on up to S1023

The full range of acquired image data is used,  ranging from SMIN to SMAX

for Rescaling of the Image

To align the acquired image data with the output scale of this permanent LUT (the “ideal” histogram), the range of S values from incoming histogram must match the number of Q values in the table

Depending on the degree to which incoming pixel values are rounded up or down, they can be made to fit a pre-set range of S values

Less severe rounding: more values     More severe rounding: fewer values

Thus, the high and low points of the S and Q ranges can be made to match

This roughly rescales the gray scale of the image

Digitization

– Results in a limited number of gray levels (pixel values) assigned to “bins” or computer files

Example:  For a gray scale of 1535, 1535 individual computer files are needed

– This range, far beyond the discernment of the human   eye, allows for windowing up and down within a                 dynamic range of 4096

-Demo: Graph of DR and GS

Rescaling corrects the brightness, and partially corrects the gray scale for each image

To do this, a computer algorithm re-maps incoming

S values to permanent Q values

Algorithm remapping S values to Q values

Re-mapping means that regardless of the specific input values, the output values are always the same

What the computer can and cannot do

The computer CAN align the average brightness of the image

Here, the computer finds the difference in average brightness between the reference histogram (permanent LUT) and the new exposure, then subtracts this from all values

By aligning the high and low points of the S and Q ranges, the computer CAN roughly rescale the gray scale, thus the contrast, of the image

What CANNOT be done by the computer is to force the specific shape of the histograms to match by altering the pixel count in each bin, shown in C

I.e., we can change anything horizontally in the histogram graph, we CANNOT change anything vertically in the graph

This would require changing which pixels across the image hold a particular initial value – We can change pixel values, not pixel counts

For these reasons, rescaling can align image brightness perfectly, but can only align image gray scale partially

Gray scale and contrast are further refined by a later step: gradation processing

Rescaling always corrects for brightness …

Because the histogram of the S values is always re-centered to the Q value range

It is this data set (the Q values) that is later fed into the anatomical LUT for gradation processing

Supplement:  Physicists’ Terms

Q Values: The “for processing” values of pixels that have undergone field uniformity and noise corrections

“S” values in this series and textbook (to minimize confusion)

Qk Values: The rescaled “for processing” pixel values that have been converted to relate to exposure levels in kerma

Qp Values: The finalized “for presentation” pixel values after gradation processing and all other postprocessing operations are complete

To minimize confusion for students, I recommend:

“S” Values for incoming raw data from the acquired histogram

                “Q” Values for RESCALED values (Qk AND Qp)

The purpose of Gradation Processing is to refine the contrast according to the anatomy

For Gradation Processing, the rescaled data set (arrow at bottom) is fed into the anatomical LUT

The anatomical LUT  customizes the gray scale and brightness according to the specific anatomy to be demonstrated

The anatomical LUT to be applied is determined when the operator selects the anatomical procedure at the console

Gradation (Gradient) Processing

Gradation:  “A gradual passing from one tint or shade to another”  =  gray scale

 

Gradient:  “The rate of change in an ascending or descending scale; the steepness of a slope

Gradation or gradient processing is named after the gradient curve of an image, (above). The left-to-right position of the curve indicates image brightness, while the steepness of the curve represents image contrast.

What Really Is A Look-Up Table?

Look-Up Tables really are tables, (not graphs)

Graphs used to represent LUTs are for human benefit in understanding them

The computer deals in numbers, not in graphs

LUT’s have 2 simple  columns: Input and  Output
Here, the input for both tables is identical, because the number set has already been rescaled

Look-up Table A produces medium contrast, Table B produces high contrast from the same data

Note that in the output column,  average gray level or center (GC) is the same for both –

(window level has not changed, only window width

The conversion of input values to output values is generated by a mathematical formula that can be represented as a  function curve on a graph

The function curve of the graph represents the particular  computer algorithm,  (algebraic formula) that input numbers are being subjected to

A graph representing a typical LUT plots the input pixel values along the bottom axis, and the converted output pixel values, reflected off the function curve, on the vertical (abscissa)

LUT function curve for enhancing  image contrast:

Original Contrast = 12 / 10 = 1.2

Converted Output Contrast =      18 / 7 = 2.6

The actual look-up table is simply a listing of the input values and then the output values resulting from these mathematical operations

 

Gradation Processing: Formulas and Curves

Graph of function converting the input to the output

All gradation processing takes place in the intensity domain

The types of formulas used for gradation processing are referred to as intensity transformations.

These are the same formulas applied whenever the radiographer windows the image after it is initially displayed

Sample Intensity Transformation Formulas
Controlling Window Width (gray scale):

Gamma Transformation:     s  =  crᵞ

Log Transformation:     s  =  clog(1 + r)

Image Negative:                                 s  =  L – 1 – r

-In each formula, r represents the input value and   s represents the output value

-Radiographers do NOT need to memorize these formu

Windowing directly applies the formula that converts input to output

-For an example, we will use the gamma transformation formula:

Gamma Transformation:   s  =  crᵞ

γ = window width control  r =  Input value s = Output value

(C = constant affecting the type of change made)

MRI of Lat T-spine (for C  = 1) : γ  =  1 γ  =  0.6 γ  =  0.4 γ  =  0.3

As γ decreases, gray scale lengthens

Aerial Photo: Airport (for C  = 1) : γ   =  1 γ   =  3 γ   =  4 γ   =  5

As γ increases, gray scale shortens

Actual function curves for  s  =  crᵞ

– for control of  window width

Function curves generated for various values of  γ for c =

The type (shape) of curve used by each manufacturer represents the algebraic function (formula) applied to set up the anatomical LUT

Different parameters entered into the formulas change the position or slope of the curve

Sample Parameters for Gradient Processing

Fuji’s Gradient Parameters: GA = amount GT = type GC = center GS = shift

-of the function curve

Sample Function Curves for Gradient Processing

Four of Fuji’s 26  Gradient Type (GT) Curves:

Note that curve M reverses the image to black on white rather than white on black (“black bone” feature

Function curves with a slope steeper than 45 degrees in the body portion of the curve represent formulas that increase contrast

Curves with a slope shallower than 45 degrees represent formulas that decrease contrast.

Sample Parameters for Gradient Processing

-for Fuji: GA = gradation amount or angle: GA < 1: Reduce contrast GA > 1: Increase contrast

GC = Center point (average brightness) around which the gradient curve rotates

Right to left position of the function curve (GS) represents changes to brightness

This has the effect of aligning the entire histogram to the ideal reference histogram for that anatomy

-for Fuji: GS = gradation shift, speed, or sensitivity, adjusts overall or average brightness, darker as the curve shifts to the right

Windowing: Reapplying Gradation Processing

When windowing:

The formulas and parameters used first set up the LUT, then output is simply read out from the LUT as input is fed into it.

(For rescaling, an already-generated  permanent LUT was used: Input values were assigned to pre-set labels and output was simply read out from the LUT)

Gradient Processing is used:

  1. During default processing when anatomical LUTs are applied
  2. Any time the displayed image is windowed by the operator

Applying Window Level and Width

Brightness and Contrast Controls Vs. Window Level and Width:

-Strictly speaking:             High Window Level means a darker image

Window level = opposite of brightness

 

High Window Width means more gray scale

Window width = opposite of contrast

Demo: CT Scans

 

Data Clipping

If the dynamic range or bit depth of a digital processing system is too limited, it is possible

for data clipping to occur when either brightness or contrast are adjusted

The dynamic range of the software, supported by the bit depth of the computer hardware, must extend sufficiently above and below typical input values to allow for all probable adjustments to the image

Data Clipping on an 8-bit (256-level) System:

A: Increasing window level (dotted line) truncated (cut off) the darkest pixels at a value of 255

B: Increasing contrast (dotted line) also cut off pixel values at 255 (before the entire line was plotted)

Dynamic Range Compression (DRC)

Bit Depth:  Range of different gray (brightness) levels for a computer, LCD monitor or other hardware device

Dynamic Range:  Range of different gray (brightness) levels made available by a computer system including its installed software

Gray Scale:  Range of different gray (brightness) levels present in a displayed image

aka “Tissue Equalization” or “Contrast Equalization”

With conventional radiography, when soft tissue techniques were used to demonstrate soft tissue areas, the bones were then depicted too light

By compressing the gray scale curve, DRC brings extremely light densities up to a darker level, and  extremely dark areas are made lighter

A: Since the bit depth of a computer can far exceed the range of human vision, memory storage space can be saved by not using the entire bit depth of the system

B: The equalized image can still be darkened or lightened as a whole

Mathematically, DRC finds the mid-point of the gray scale curve, then progressively reduces pixel values above this point, and progressively increases pixel values below it

Applied to a degree visibly affecting the image, this results in tissue equalization, a cutting off  of the darkest and lightest densities

Tissue equalization effects of DRC:  Since the darkest areas (lung fields below) are lightened, while the lightest areas (mediastinum below) are darkened, the resulting densities range from light gray to dark gray.

-This simulates the traditional “soft tissue technique”

Example of Fuji’s Dynamic Range Control

Dynamic Range Compression is better described as … Gray Scale Truncation

A clipping off of the extreme ends of the gray scale

Using DRC for Tissue Equalization

-Gray scale truncation can be very confusing:

-Elimination of darkest and lightest densities in gray scale range

results in a grayer-looking image!

-Unlike conventional shortening of gray scale which results in increased contrast