227-0391-00: Medical Image Analysis
Section 2
Enhancement and Pre-processing
Swiss Federal Institute of Technology Zurich
Eidgenössische Technische Hochschule Zürich
Last Edit Date: 06/27/2025
Disclaimer and Term of Use:
We do not guarantee the accuracy and completeness of the summary content. Some of the course material may not be included, and some of the content in the summary may not be correct. You should use this file properly and legally. We are not responsible for any results from using this file
This personal note is adapted from Professor Ender Konukoglu, Professor Mauricio Reyes, and Doctor Ertunc Erdil. Please contact us to delete this file if you think your rights have been violated.
This work is licensed under a Creative Commons Attribution 4.0 International License.
Intensity normalization¶
Problem source¶
Intensity variations between images coming from the differences in
- Scanners
- Protocols
- Acquisition software
- Reconstruction method
Particularly important for MRI due to lack of absolute intensities
Less of a problem for modalities with absolute intensities, e.g., Hounsfield Unit in CT, hower variations can still occur
Intensity variations can cause adverse effects for the rest of the processing steps
Particularly problematic for machine learning methods. Intensity difference between training and test samples is called domain effect shift. Think of images at night and day
Remains an open problem
In the ideal case
Whenever
Two images are compared, e.g., registration
Two groups are compared, e.g., statistical analysis
A model's parameters are estimated from a set of images, i.e., training and estimated model is applied on a new set of images, i.e., testing
We would like images to have the same intensity "characteristics." Notion of "characteristics" refer to intensity distribution, including global and local intensity and contrast.
Approach 1: Min-max¶
Matching the range, the Min-max normalization is
$$f(j) = \frac{j - j_{\text{min}}}{j_{\text{max}} - j_{\text{min}}} \left( i_{\text{max}} - i_{\text{min}} \right) + i_{\text{min}}$$
where $i$ and $j$ are the intensities of the two images.
Max and min values are sensitive to outliers
Often intensities corresponding to $\epsilon$% and $1 - \epsilon$% of the CDF are used instead, e.g., $\epsilon = 2$
Commonly used in machine-learning based methods as a preprocessing step
Can solve global intensity shift and multiplicative factors
Cannot solve contrast differences
Approach 2: Matching mean and standard deviation¶
Matching second order statistics - mean and standard deviation normalization is
$$ \begin{align} f(j) &= (j - \mu_j) \frac{\sigma_i}{\sigma_j} + \mu_i \\ \mu_i &= \frac{1}{N} \sum_{x=1}^{N} i(x) \\ \sigma_i^2 &= \frac{1}{N-1} \sum_{x=1}^{N} \left( i(x) - \mu_i \right)^2 \end{align} $$
Less sensitive to outliers but still robust statistics may be used for better behavior, e.g., median, robust variance
Often used in machine-learning based methods
Can solve global intensity shift and multiplicative factors
Cannot solve contrast differences
Short summary on approaches 1 and 2
Both min-max and mean-std matching are linear mappings (linear except the bias or linear in the homogeneous coordinates). Both of these transformations cannot change the contrast of an image. In order to be able to change the contrast, we need non-linear transformations in the intensity space.
Approach 3: Histogram normalization with landmarks¶
This kind of piecewise linear mapping (quartiles and min-max as landmarks) can be represented as
$$ f(j) = \begin{cases} (j - j_{\text{beg}}) \frac{i_1 - i_{\text{beg}}}{j_1 - j_{\text{beg}}} + i_{\text{beg}} & j \le j_1 \\ (j - j_1) \frac{i_2 - i_1}{j_2 - j_1} + i_1 & j_1 < j \le j_2 \\ (j - j_2) \frac{i_3 - i_2}{j_3 - j_2} + i_2 & j_2 < j \le j_3 \\ (j - j_3) \frac{i_{\text{end}} - i_3}{j_{\text{end}} - j_3} + i_3 & j_3 < j \\ \end{cases} $$
Matching lanrmarks of image histograms
Piece-wise linear map: non-linear mapping
Different landmarks are possible
- min and max
- mean or median
- quartiles, deciles
- modes
Less senitive to outliers
Widely used
Population-wide used:
- Estimate landmark positions from population data as average
- Map the new image's landmarks to the averages
Can change the contrast because of the non-linearity of the mapping
Matching only the locations of the landmarks does not make the histograms perfectly euqal
We still might have some problems when matching histograms of images with large lesions and healthy brans
- Presence of pathologies will change histograms
- Matching pathology bearing images is hard
- Robust statistics and outlier detection can help
Several things to pay attention to
- Image content
- Histogram matching does not know about image content
- All pixels are considered independent
- No spatial information / correlation between neighboring pixels
- Matching gradients has been proposed
- Object size
- Differences in object size can be a problem
- Perfect histogram match would not be preferred in that case
- Use mode matching if object sizes are different
Problem definition¶
Additive noise
$$J(x) = I(x) + \epsilon(x)$$
$\epsilon(x)$ is often considered to be i.i.d., for example, Gaussian noise $\epsilon ~ \mathcal{N}(0, \sigma)$
Multiplicative noise
$$J(x) = I(x) \epsilon(x)$$
For example, speckle in ultrasound and optical coherence tomography
More complicated, for example, noise in MR magnitute image
$$J(x) = \sqrt{\left( I_r(x) + \epsilon \right)^2 + \left( I_i(x) + \eta \right)^2}$$
$\epsilon, \eta \sim \mathcal{N}(0, \sigma)$, Rician noise
Given the noisy image $J$ remove noise to get $I$
Approach 1: Linear filter / convolutional¶
Convolution is defined as
$$ \begin{align} \tilde{I} &= J \cdot S \\ \tilde{I}(x, y, z) &= \int_r \int_p \int_q J(x-r, y-p, z-q) S(r, p, q) dr~dp~dq \\ \tilde{I}(i, j, k) &= \sum_{r} \sum_{p} \sum_{q} J(i - r, j - p, k - q) S(r, p, q) \end{align} $$
where $S$ is the structural element (kernel), $J$ is the pixel from the image we want to denoise, and $\tilde{I}$ is the denoised image.
Extremely efficient to apply
Easy to implement
Blurs edges
Not context aware
Sensitive to outliers
Remark
It is not possible to remove noise and not blur edges at the same time with a linear filter. We need non-linear filtering for this.
Approach 2: Median filter¶
For each location, rank order all neighboring intensities
Assign the median value as the result
1, 2, 2, 2, 2, 3, 3, 9
Median is 2
Sliding window similar to convolution
Other rank order filters such as min and max, are defined similarly
Non-linear filters
Two rank filters are not commutative: $\text{min}(\text{median}(I)) \neq \text{median}(\text{min}(I))$
Roubustness and edge preservation
Easy and efficient implementation
Does not introduce new intensities: (i) keeping the intensities integer, (ii) applying median filtering to labels - in a post-processing step - will not introduce new labels and remove islands, e.g., segmentation
Patch result
Image content can change - adding and removing structures
Approach 3: Non-local means¶
Very widely used model, very competitive results
Extension of bilateral filtering
Most noise supression methods can be put in the form
$$I(x) = \sum_{y \in \Omega} w(x, y) J(y)$$
where $0 \le w(x, y) \le 1$ and $\sum_{y \in \Omega} w(x, y) = 1$, $\forall x$. For example, we can use mean and Gaussian filter, the weights $w(x, y)$ changes accordingly.
Non-local means uses $w(x, y)$ to assess similarity between image information at $x$ and $y$
$$w(x, y) = \frac{1}{Z(x)} \exp \left\{ - \frac{\| J(\mathcal{N}(x)) - J(\mathcal{N}(y)) \|_2^2}{h^2} \right\}$$
$Z(x)$ is the normalization constant, $h$ is the degree of filtering and $\mathcal{N}(x)$ neighborhood around $x$.
In the example image above, all the pixels in the circles are neighboring pixels $q_1, q_2, q_3$ corresponding to $\mathcal{N}(x)$, the target pixel is $p$ corresponding to $\mathcal{N}(y)$. If the pixel is similar to the target, then the corresponding weight is higher.
While smoothing point $x$ use areas with similar image content
If noise is random then averaging similar areas should get rid of it
Uses redundancy in the images, i.e., local structures repeat