Digital image processing-histogram equalization

Source: Internet
Author: User

 

In the digital image processing class, the teacher assigned Seven lab questions, which are not limited in language, but cannot call off-the-shelf algorithms. These questions are difficult, however, the question itself basically covers all the important content in this course. To help students and fellow students complete their exercises and review the classic algorithms easily, I will analyze one question and one question.

 

Histogram Equalization (test images:
Fig1.jpg, fig2.jpg)

()
Write a computer program for computing the histogram of an image.

(B)
Implement the histogram equalization technique.

(C) Your program must be
General to allow any gray-level image as its input.

As
A minimum, your report shoshould include the original image, a plot of its
Histogram, a plot of the histogram-equalization, transformation function,
Enhanced image, and a plot of its histogram.


Background

Histogram equalization is usually used to increase the global contrast of many images, especially when the contrast of useful data is very close. In this way, the brightness can be better distributed on the histogram. This function can be used to enhance the local contrast without affecting the overall contrast. histogram equalization is implemented by effectively expanding the commonly used brightness.

 

This method is very useful for images with too bright or too dark backgrounds and prospects, this method, in particular, can bring better bone structure display in X-ray images and better details in photos of over-exposure or under-exposure. One of the main advantages of this method is that it is a fairly intuitive technique and reversible operation. If the equalization function is known, the original Histogram can be restored, and the amount of computing is not large. One disadvantage of this method is that it does not select the processed data. It may increase the contrast of background noise and reduce the contrast of useful signals.

 

Principles in books


Matlab implementation

Sourcepic1_imread('fig2.jpg '); % read the source image <br/> % The following is a color image <br/> % [m, n, o] = size (sourcePic ); <br/> % grayPic = rgb2gray (sourcePic); <br/> grayPic = sourcePic; <br/> [m, n] = size (grayPic ); <br/> subplot (1,256, 1); % displays the source image <br/> imshow (grayPic); <br/> gp = zeros ); % calculate the probability of occurrence of each gray scale <br/> for I = <br/> gp (I) = length (find (grayPic = (I-1 ))) /(m * n); <br/> end <br/> subplot (, 2); % display the original image histogram <br/> bar (, gp ); <br/> title ('original image histograms '); <br/> xlabel ('grayscale value'); <br/> ylabel ('probability of occurrence '); <br/> newGp = zeros (1,256); % calculate the probability of occurrence of each gray scale <br/> S1 = zeros (1,256 ); <br/> S2 = zeros (1,256); <br/> tmp = 0; <br/> for I = <br/> tmp = tmp + gp (I ); <br/> S1 (I) = tmp; <br/> S2 (I) = round (S1 (I) * 256 ); <br/> end <br/> for I = 1:256 <br/> newGp (I) = sum (gp (find (S2 = I ))); <br/> end <br/> newGrayPic = grayPic; % fill in the new gray value of each pixel <br/> for I = <br/> newGrayPic (find (grayPic = (I-1) = S2 (I ); <br/> end <br/> subplot (2,2, 3); <br/> imshow (newGrayPic); <br/> subplot (2,2, 4 ); % display the histogram after equalization <br/> bar (0: 255, newGp); <br/> title ('histogram after equalization '); <br/> xlabel ('grayscale value'); <br/> ylabel ('probability of occurrence '); <br/> 

 

 

Effect and demonstration

Fig1.jpg source image, after histogram equalization

Fig2.jpg source image, after histogram equalization

 

Experience

Histogram equalization mainly uses the statistical idea to establish the relationship between the original image and the gray-scale value of the new image, and ultimately balance the gray-scale of the image. The final result shows that the effect of the second image is better. Although the contrast of the first image increases, it also produces a lot of salt and pepper noise.

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.