Figure 1. Steps in altering the grayscale distribution.( 1) From pixel grayscale, find CDF value (2). Trace this value in the desired CDF (3). Replace pixel value by grayscale value having this CDF value in desired CDF (4). (Image and description taken from [1])
For this experiment, we have used the image in upper left of Figure 2. It is a lighthouse which was already installed in the Windows 7 operating system. It was turned into grayscale (upper left). The PDF was obtained (lower left) and its CDF (lower right). As one may notice, the PDF is not flat and evenly distributed. This will be the image and the CDF that we shall use. Here is some code snippets I used:
Im = imread(“E:AP 186Act 5LH.jpg”);
Im = rgb2gray(Im)
imwrite(Im, “E:AP 186Act 5LH_gray.png”);