Image enhancement is the most fundamental and simple process of digital image processing. In this process, the intensity level of an image is manipulated to get a better output image. For this purpose, we will use the mathematical operation of gray level transformation, also known as intensity transformation. In this article, we are going to understand gray-level transformations in detail along with their applications.
Image enhancement in the spatial domain is based on the following expression:
g(x. y) = T[f(x, y)]
where, f (x, y) is the input image, g(x, y) is the output image and T is an operator on f defined over the neighborhood of point (x, y). The neighborhood of an arbitrary point (x, y) is shown in the figure below:

The simplest and the smallest possible of all the neighborhoods of a point is 1 X 1. When the mapping is defined over the 1 X 1 neighborhood of points, then the mapping is said to be Gray level (or Intensity) Transformation (or mapping). The output image, g depends on the value of f at a single point (x, y) and T alone.
The gray level transformation is given by the expression:
s = T(r)
where, s and r is the intensity value of g and f value of the point (x, y)
Table of Contents
- Introduction
- Linear Transformation and Image Enhancement
- Basic Intensity Transformation Function
- Piecewise Linear Transformation Function
- Non-linear Gray Level Transformation
- Applications
- Types of Image Enhancement Methods
- Conclusion
- FAQs
Linear Transformation and Image Enhancement
Gray level transformation can be linear or non-linear operation. Linear transformation possesses the property of homogeneity and additivity. Linear gray level transformation techniques which are used in image enhancement are discussed in detailed manner in the subsequent sections.
1. Basic Intensity Transformation Function
Gray level transformation is one of the simplest image processing techniques. In digital image processing, the transformation functions are stored in a table. The mappings are implemented via table lookups. For an n-bit image, a lookup table will have 2n entries.
There are three basic types of intensity functions used in gray level transformation:
- Negative Image
- Log Transformation
- Gamma Transformation

Negative Image
The negative of a image having intensity range [0, L - 1] can be found using the following transformation:
s = T(r) = L - r - 1

This technique is used to enhance white or light color detail in dark background, as dark color in light background is easily visible than light color in dark background. Here dark becomes light and light becomes dark.
Log Transformation
The log transformation is of the form:
s = T(r) = c log (1 + r)
where, c is constant and r ≥ 0.

In log transformation, the higher range of intensity level is mapped to a lesser range of intensity level at the brighter side, whereas the lesser range of intensity level is mapped to higher range of intensity level at the darker side. The log transformation expands the dark pixels. Log transformation is applied when the intensity levels are very large, for example, 0 to 10^6. This is because transformation compresses the intensity levels of input level.
The inverse logarithmic transformation is called exponential transformation. It has the opposite behaviour that of logarithmic transformation. The higher range of intensity level is mapped to higher range of intensity level at the brighter side, whereas the lesser range of intensity level is mapped to a lesser range of intensity level at the darker side.
Power Law (Gamma) Transformation
The power law (or gamma) transformation is of the form:
s = T(r) = c * r^γ
where, c, γ are constants; c, γ > 0

For various values of γ, there exists a different power law transformation. At γ < 1, the higher range of intensity level is mapped to a lower range of intensity level at the brighter side, while the lower range of intensity level is mapped to higher range of intensity level at the darker side. At γ > 1, the behaviour is opposite that of γ < 1. Here, the higher range of intensity level is mapped to a higher range of intensity level at the brighter side, while the lower range of intensity level is mapped to lower range of intensity level at the darker side. If γ = 1, then the transformation becomes identity transformation.
Power law transformation has application in gamma correction. We will see about this in detail in the latter section.
2. Piecewise Linear Transformation Function
Piecewise linear transformation is an approach which is useful for complex and practical enhancement.
Contrast Stretching
Contrast stretching is used to expand the intensity levels range of a low contrast image.
The transformation for contrast stretching is given by
s = c1 * r ; 0 ≤ r ≤ r1
= c2 * r + k1 ; r1 < r ≤ r2
...
= c(n) * r + k(n-1) ; r(n-1) < r ≤ r(max)
[c(p+1) * r(p) + k(p) = c(p) * r(p) + k(p-1)]

The transformation function is continuous and monotonically increasing.
Intensity-Level Slicing
Intensity-level slicing is used in highlighting a detail or flaw by enhancing a certain range of intensity levels. There are various basic approaches for intensity-level slicing. But they are generally a variation of one of the two basic approaches.
One basic approach is to give one color to pixels having a range of intensity levels of interest and give another color to remaining pixels. This will result in a binary image. The transformation function is:
s = 1 ; r1 < r < r2
= 0 ; otherwise
Another approach is to give one color (dark or bright) to pixels having a range of intensity levels of interest to highlight them and do not change the color of the remaining pixels. The transformation function is:
s = k ; r1 < r < r2
= r ; otherwise

Non-linear Gray Level Transformation
Bit-Plane Slicing
Pixel values are integers having bit value. A n-bit image will have 2^n intensity or gray levels. In this bit-plane slicing, instead of highlighting the intensity level. We will highlight the contribution of each bit in the image. Lower order bits generally have no contribution whereas higher order bits have maximum contribution. We multiply kth bit with 2^(k-1) to visualise its contribution. Note that an n-bit image will have n bit planes. Bit-plane slicing is used in image compression as lower order bits are not stored.
Histogram Processing
Histograms of high contrast images have intensity values spanned across the maximum and minimum intensity levels. We try to transform the histogram of a given input image to a uniform distribution using the technique of histogram equalization. Result of histogram equalization is always uniform distribution. It is independent of the probability distribution function of the input image. Hence we obtain a high contrast image.

Application
Gamma Correction (or Encoding)
Generally, the response of image acquiring, printing or displaying image is affected by power law. The cathode ray tube (CRT) has intensity to voltage response which is a power function with γ = 1.8 to 2.5. The process used to correct them is called gamma correction, also known as gamma encoding.
Example

In the figure, the original image is viewed on the monitor as a response of power law with γ = 2.5. As a result the image appears darker. So we perform gamma correction using inverse operation. That we apply power law transformation with γ = 1/2.5 = 0.4. And when this gamma corrected image is viewed on image the intensity have γ = 2.5 * 0.4 = 1 as compared to the original image. Hence, we get the original image displayed on the monitor as it is.
Thresholding
Thresholding is the application of gray level transformation in Image Segmentation. We separate the image as two (in case of binary thresholding) or more based on the range of intensity values.
The transformation function of thresholding is given by:
s = k1 ; 0 ≤ r < r1
= k2 ; r1 ≤ r < r2
...
= k(n) ; r(n) ≤ r < L
For example the image is separated to two region with intensity values [0, 3L/4) and [3L/4, L).

Types of Image Enhancement Methods
Image enhancement methods can be classified into one of the two types - spatial domain and frequency domain. In spatial domain, we manipulate the pixel of an image directly. Whereas in frequency domain we manipulate the frequency i.e. intensity of pixels. The image enhancement filters in the spatial domain are convoluted with the input image to form the enhanced image. But convolution is a costly operation. Hence, we transform spatial domain to frequency domain. In frequency domain, the image enhancement filters is multiplied with the transformed input image. We transform back to spatial domain from frequency domain to get the enhanced image. To transform from spatial domain to frequency domain we use fourier transform and from frequency domain to spatial domain we use inverse fourier transform.

Advantages and Disadvantages
Advantages
- It makes light and dark areas more distinct in an image.
- Helps to see details more clearly.
- Makes it easier to interpret and analyze images.
Disadvantages
- May amplify unwanted elements like noise or artifacts.
- Adjustments can be subjective, leading to inconsistent outcomes
Conclusion
Gray level transformation is one of the simplest image processing techniques. It is useful for enhancing images and preparing images for further analysis. By understanding and applying different gray level transformation techniques, we can understand and use grayscale images in a better way.