By Nemuel Daniel Pah 14/11/05 Module 2 Histogram Manipulation (sliding, stretching, and complementing)
Class Image enhancement/Restoration
Description Histogram sliding is a process to slide histogram distribution of an image towards brighter or darker gray-scale. The process brighten/darken the input image. It is performed by adding/subtract a constant value to all pixels in the image.
Histogram stretching is a process to stretch/shrink histogram distribution of an image. The process improves the image contrast. It is performed by multiply a constant value (>1 for stretching or <1 for shrinking) to all pixels in the image.
Histogram complementing is a process to convert bright pixel to dark and dark pixels to bright proportionally.
Application Histogram sliding is used to correct over/under exposure image. Histogram sliding is used to improve contrast in an image. Histogram complementing is used to the visibility of brightness details in bright region of an image.
Implementation (histogram sliding) Calculate histogram of gray level image. Determine the value of sliding constant by which all histogram distribution will be shifted. Add the constant (K) to all pixels:
Pemrosesan Citra Page 2 of 6 Copyright JTEUS, 2005 D:\My Documents\JTEUS\Citra\BookOrg\Modul2 HistMan\Modul2.doc By Nemuel Daniel Pah 14/11/05 Draw the histogram of both the input and output images, and observe the effect of histogram sliding to the histogram of the image.
Example (histogram sliding)
An under-exposed image with its histogram
The histogram slided image with (K=100)
Matlab Script (histogram sliding) The above histogram sliding process was created using the following script (modul2a.m):
A=imread('gambar1.jpg','jpg');
figure(1); imshow(A);
figure(2); imhist(A); axis([0 255 0 20000]);
Ad=double(A);
ImOut=Ad+100;
ImOut=uint8(ImOut);
figure(3); imshow(ImOut);
Pemrosesan Citra Page 3 of 6 Copyright JTEUS, 2005 D:\My Documents\JTEUS\Citra\BookOrg\Modul2 HistMan\Modul2.doc By Nemuel Daniel Pah 14/11/05 figure(4); imhist(ImOut); axis([0 255 0 20000]);
Implementation (histogram stretching) Calculate histogram of gray level image. Determine the stretching factor by which all histogram distribution will be stretched. Multiply all pixels with the stretching factor (S):
Draw the histogram of both the input and output images, and observe the effect of histogram complementing to improve image contrast.
Example (histogram complementing)
An image with its histogram
The complemented image with its histogram
Pemrosesan Citra Page 6 of 6 Copyright JTEUS, 2005 D:\My Documents\JTEUS\Citra\BookOrg\Modul2 HistMan\Modul2.doc By Nemuel Daniel Pah 14/11/05 Exercise 1. Refer to Matlab manual to understand each line in the above script. 2. Find the appropriate histogram manipulation to enhance gambar1 until the image is nice and clear, while the piano keys are still sharp.