Intensity Transformation
A transformation $q=T(p)$ is defined on pixels (location-insensitive) and transforms the scale of intensity values $[p_0, p_k]$ to a new scale $[q_0, q_k]$.
Assume L=256, i.e. 8-bit quantization.
Transformations:
- Identity function
- The "negative" function or "invert" function
- "Negative" function is a bit misleading because this does not lead to negative values
- "invert" is also misleading, it's not just 1/p.
- Boost low grey levels (above identity function):
- n-th root
- logarithm
- Penalize low grey levels (below identity function):
- n-th power
- inverse log
Example: Mammogram processing
On raw image, the breast is very dark (low intensity) against a light background (high intensity). To get a picture that is easier to interpret:
- Log transform: boost the low intensity values so we see more nuanced patterns that were before almost all black
- Invert: white is easier to see against black background
- Increase contrast based on histogram analysis
W.r.t. the log transform: teacher said image is collected as such:
$$I(x,y)=I_0 exp(-\mu(x,y) d(x,y))$$
The log transform then is
$$I(x,y)=log(I_0) -\mu(x,y) d(x,y)$$
But what is the meaning of $\mu(x,y) d(x,y)$ here? Is it the mean intensity across multiple channels (so does 'd' stand for depth?)
Histogram analysis
Histogram: Pixel counts (y-axis) for each intensity value (on the x-axis).
The normalized histogram divides by the number of pixels to get the relative contribution of intensity values.
numpy.histogram
Histogram matching
Using a LUT mapping
LUT: look-up-table.
We can transform the intensity of an input image to match the histogram of a target image. This can help for example converting lower-quality scans (when better equipment is not available for whatever reason) into a more usable representation.
To achieve this we compute the cumulative distribution function over the histogram of the input and target image.
numpy.cumsum
Once you have those both cumulative plots ...
... for each input pixel intensity p, with count y, map p to the target intensity q for which the count is also y. This makes the histogram of the input look like the target's histogram.
Make sure to normalize the data so we can meaningfully compare the histograms.
Linear Contrast Stretching
In a natural image a lot of the intensity values may be focused in a narrow dense area. In (processed) mammogram target distributions we see instead the distribution is spread out and contains both low intensity and high intensity values.
We can try to match this target distribution by "stretching" the dense input distribution.
Define window over input $p_0 - p_k$ where the signal of interest is. For different applications (e.g. isolating particular organs) we can adjust this window.
Goal: map range over p to range over q.
$$q=T(p)=q_0 + (q_k - q_0 )[ \frac{p-p_0}{p_k-p_0}]$$
- Rescale $[p_0, p_k]$ to $[0,1]$
- See right part of RHS
- Rescale to desired output range $[q_0, q_k]$
- SEE left part of RHS
N.B. you only apply the linear stretching within a desirable range.
This means you should clip values outside that range and set them to the edge values of the interval, e.g. using np.clip().