Image enhancement simply means, transforming an image *f* into image *g* using *T*. Where *T* is the transformation.

The values of pixels in images *f* and *g* are denoted by *r* and *s*, respectively. As said, the pixel values *r* and *s* are related by the expression, ** s = T(r) **where

*T*is a transformation that maps a pixel value

*r*into a pixel value

*s*.

Enhanced images provide better contrast of the details that images. For example, Medical Image Analysis, satellites images etc.

There are three basic types of transformations functions used for image enhancement.

- Linear,
- Logarithmic,
- Power-Law

Figure 1 shows Plot of various transformation functions. The Identity and Negative curves fall under the category of linear functions. Identity curve indicates that input image is equal to the output image.

The Log and Inverse-Log curves fall under the category of Logarithmic functions and *n*th root and *n*th power transformations fall under the category of Power-Law functions.

**Image Negation**

The negative of an image with grey levels in the range [0, L-1] is obtained by the negative transformation shown in figure above, which is given by the expression as * s = L – 1 – r. *This expression results in reversing of the gray level intensities of the image thereby producing a negative like image. In negative transformation, each value of the input image is subtracted from the L-1 and mapped onto the output image. This is particularly useful for enhancing white or gray details embedded in dark regions of an image.

Download Matlab code for Image Negation Graylevel-transformation-code.zip (630 downloads)

Input Image

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | close all; clear all; F=imread('lena.bmp'); //Read Image F=imresize(F,0.5); //Resize image by scale 0.5 figure(1); subplot(1,2,1); //show image in first column section. title('ORIGINAL IMAGE'); imshow(F); // convert color image to gray image g = 0.2989 * F(:,:,1) + 0.5870 * F(:,:,2) + 0.1140 * F(:,:,3); subplot(1,2,2); title('GRAY IMAGE'); imshow(g); G=256-F; // formula to image negation. figure(2); title('negative image'); imshow(G); |

Output

**Log Transformations**

The log transformation curve shown in figure 1, is given by following expression, *s = c log(1 + r) *Where c is a constant and it is assumed that r ≥ 0. The shape of the log curve in figure 1 shows that this transformation maps a narrow range of low-level gray scale intensities into a wider range of output values. And similarly maps the wide range of high-level gray scale intensities into a narrow range of high level output values. The opposite of this applies for inverse-log transform. This transform is used to expand values of dark pixels and compress values of bright pixels.

For example, Log function *s = c log(1 + r)* for *r* varying between 0 and 255, output s results in 0 and 2.41 where *c*=1. So, the range [0, 2.41] should be mapped to [0, L-1] for getting a meaningful image.

Matlab code Graylevel-transformation-code.zip (630 downloads)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | close all; clear all; //Load, Resize & Show Image F=imread('lena.bmp'); F=imresize(F,0.5); figure(1); subplot(1,2,1); title('ORIGINAL IMAGE'); imshow(F); //Convert to grayscale g = 0.2989 * F(:,:,1) + 0.5870 * F(:,:,2) + 0.1140 * F(:,:,3); C=50; //formula for log function transformation H=uint8(C.*log(double(1+g))); subplot(1,3,1); imshow(F); title('Original Image'); subplot(1,3,2); imshow(g); title('Gray Image'); subplot(1,3,3); imshow(H); logtext=sprintf('Logarithmic Operator for C=%2.1f',C); title(logtext); |

Output

**Power-Law Transformations**

The *n*th power and *n*th root curves shown in fig. A can be given by the expression as * s = c r ^{γ }*This transformation function is also called as

*gamma*correction. For various values of γ different levels of enhancements can be obtained. It is used to correct power law response phenomena. The different display monitors display images at different intensities and clarity. That means, every monitor has built-in gamma correction in it with certain gamma ranges and so a good monitor automatically corrects all the images displayed on it for the best contrast to give user the best experience. The gamma variation changes ratio of red green & blue along with intensity in color images. The difference between the log-transformation function and the power-law functions is that using the power-law function a family of possible transformation curves can be obtained just by varying the λ. This process is also called a gamma correction.

Matlab Code Graylevel-transformation-code.zip (630 downloads)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | close all; clear all; F=imread('lena.bmp'); F=imresize(F,0.5); g = 0.2989 * F(:,:,1) + 0.5870 * F(:,:,2) + 0.1140 * F(:,:,3); C=1; gamma=1.2; I=uint8(C.*((double(g)).^gamma)); //formula for Power Law Transformation. subplot(1,3,1); imshow(F); title('Original Image'); subplot(1,3,2); imshow(g); title('Gray Image'); subplot(1,3,3); imshow(I); powtext=sprintf('Power Law Operator for C=%2.1f and gamma=%0.2f',C,gamma); title(powtext); |

Output

Graylevel-transformation-code.zip (630 downloads)