Image Processing Contrast Image Histogram Contrast Data Intensities

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

DSIP EXPHISTOGRAM. AIM: To write a matlab program for histogram equalisation.

THEORY: Histogram equalization is a method in image processing of contrast adjustment using the image's histogram. This method usually increases the global contrast of many images, especially when the usable data of the image is represented by close contrast values. Through this adjustment, the intensities can be better distributed on the histogram. This allows for areas of lower local contrast to gain a higher contrast. Histogram equalization accomplishes this by effectively spreading out the most frequent intensity values. The method is useful in images with backgrounds and foregrounds that are both bright or both dark. In particular, the method can lead to better views of bone structure in x-ray images, and to better detail in photographs that are over or under-exposed. A key advantage of the method is that it is a fairly straightforward technique and an invertible operator. So in theory, if the histogram equalization function is known, then the original histogram can be recovered. The calculation is not computationally intensive. A disadvantage of the method is that it is indiscriminate. It may increase the contrast of background noise, while decreasing the usable signal. Histogram equalization often produces unrealistic effects in photographs; however it is very useful for scientific images like thermal, satellite or x-ray images, often the same class of images that user would apply false-color to. Also histogram equalization can produce undesirable effects (like visible image gradient) when applied to images with low color depth. For example, if applied to 8-bit image displayed with 8-bit gray-scale palette it will further reduce color depth (number of unique shades of gray) of the image. Histogram equalization will work the best when applied to images with much higher color depth than palette size, like continuous data or 16-bit gray-scale images. Steps: Consider a discrete grayscale image {x} and let ni be the number of occurrences of gray level i. The probability of an occurrence of a pixel of level i in the image is

L being the total number of gray levels in the image, n being the total number of pixels in the image, and px(i) being in fact the image's histogram for pixel value i.Let us also define the cumulative distribution function corresponding to px as

which is also the image's accumulated normalized histogram. We would like to create a transformation of the form y = T(x) to produce a new image {y}, such that its CDF will be linearized across the value range, i.e. where K=L-1.

Thus the final equalised image will be

CONCLUSION: Thus we have successfully implemented histogram Equalisation.

Matlab Program: clc p=imread('face.gif'); [row,col]=size(p); z=zeros(row,col); x=zeros(2,row); %displaying subplot(2,2,1) imshow(p) xlabel('Original Image') subplot(2,2,2) imhist(p) xlabel('Original histogram') sum=0; %Calculating no of pixels in each grey level........ for i=0:1:255 for j=1:1:row for k=1:1:col if(i==p(j,k)) x(2,i+1)=x(2,i+1)+1; end end end sum=sum+x(2,i+1); x(1,i+1)=i; end %Calculating pDF

for i=1:1:row x(2,i)=x(2,i)/sum; end %Calculating CDF for i=1:1:row if(i~=1) x(2,i)=x(2,i)+x(2,i-1); end end %(L-1)*CDF and assigning new grey levels...... for i=1:1:row x(2,i)=round(x(2,i)*(row-1)); for j=1:1:row for k=1:1:col if(x(1,i)==p(j,k)) z(j,k)=x(2,i); end end end end subplot(2,2,3) imshow(uint8(z)) xlabel('Equalised Image') subplot(2,2,4) imhist(uint8(z)) xlabel('Equalised Histogram') OUTPUT:

800 600 400 200 0 0 Original Image 50 Original histogram 100 150 200 250

1000 800 600 400 200 0 0 Equalised Image 50 Equalised Histogram 100 150 200 250

You might also like