The poor contrast image obtained from the web is shown below.
(http://www.fotosearch.com/UNZ180/u17712232/)
It has dimensions of 160 x 170 pixel units. To enhance the contrast of the image, its Probability Distribution Function (PDF) was first determined.
From the histogram, the spread across the x axis(gray level) is not that wide since the image is of poor contrast. Using the cumsum function from scilab, the Cumulative Distribution Function (CDF) of the image was plotted.
Then, pixel by pixel, the image pixel values were backprojected by replacing the pixel value by the values on the y-axis of the pixel value from the CDF, and using them on the enhanced image.
The enhanced image is shown below with its PDF and CDF plots.
It can be observed that the range of spread along the gray level axis of the PDF is great, and the CDF's slope is equal to 1, which shows a successful enhancement of the image's contrast.
The program I used is:
im=imread('water1.jpg'); //g=::1,(im);
val=[];
num=[];
counter=1;
for i=0:1:255
[x,y]=find(im==i); //finds where im==i (or g==i)
val(counter)=i;
num(counter)=length(x); //find how many pixels of im have value of i
counter=counter+1;
end
pixels=size(im,1)*size(im,2) //27200
plot1=plot(val, num);
num2=num/pixels;
plot2=plot(val, num2); //normalized
plot(val,cumsum(num2)); //CDF
im2 = [];
for ii = 1:1:size(im,1)
for jj = 1:1:size(im,2)
cdf = cumsum([number/(length(im2))]);
newim(ii,jj) = cdf(im(ii,jj));
imwrite(im2, 'waterfinal.jpg');
end
end
rating-10, because I have successfully enhanced the contrast of my image
Acknowledgments:
Cole and Angel- for assisting me in the process of backprojecting my image.
Paul - for helping me find the error in my code
Tuesday, July 1, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment