Histogram Equalization Project Using MATLAB with Source Code
Histogram Equalization
Introduction:
This application note defines a technique of Digital imaging processing which allows medical images to have better contrast. This is achieved via the histogram of the image, making use of a technique that allows the places with minimal contrast to improvement increasing contrast by circulation out the most regular intensity values. For example, in digital x-rays in what kind of colors achieved are a palette of whites and blacks, unlike types of colors give the physician an idea of the type of density that he or she is perceiving. Therefore white components are most likely to indicate bone or water and black structures mean air. Whenever pathologies are existing in an image, attempting to define the region of the lesion or object of interest may be a challenge, because a variety of structures are usually layered one over the other. like in the case of the chest the heart, lungs, and blood vessels are so near with each other that contrast is critical for accomplishing an accurate detection of problems.
Digital Image
A digital image is a binary symbol of a 2D image. The digital exemplification is an array of picture elements called pixels. Each of these pixels has a numerical value which in homochromatic images represents a grey level
Histogram of an image
Histogram is the approximation of the probability distribution of a particular type of data. An image histogram is a type of histogram which offers a graphical representation of the tonal distribution of the gray values in a digital image. By viewing the image’s histogram, we can analyze the frequency of appearance of the different gray levels contained in the image. In we can see an image and its histogram.
The histogram displays us that the image contains only a fraction of the entire range of gray levels. In this case there are 256 gray levels and the image only has values Between 50 to 100. Therefore this image has low contrast.
What is a good Histogram?
A good histogram is that which covers all the expected values in the gray scale used. This type of histogram proposes that the image has good contrast and that particulars in the image may be observed more easily.
Methods for histogram equalization
• Histogram expansion
• Local area histogram equalization (LAHE)
• Cumulative histogram equalization
• Par sectioning
• Odd sectioning
Histogram Processing
The histogram of a digital image with gray levels from 0 to L-1 is a discrete function h(rk)=nk, wherever:
rk is the kth gray level
nk is the # pixels in the image with that gray level
n is the total number of pixels in the image
k = 0, 1, 2, …, L-1
Normalized histogram: p(rk)=nk/n
sum of all constituents = 1
Histogram Equalization
Histogram equalization output are alike to contrast stretching however offer the advantage of full automation, meanwhile HE automatically determines a transformation function to produce a new image with a uniform histogram.
Fig.1 Dark Image vs High contrast histogram image
Fig.2. Histogram Equalized image
Histogram Matching (or Specification)
Histogram equalization does not allow cooperating image enhancement and makes only one result: an approximation to a constant histogram.
Sometimes still, we need to be able to specify particular histogram forms capable of highlighting certain gray-level ranges.
practical approach
FLOW CHART
MATLAB Source Code for Histogram Equalization
clc;
clear all;
close all;
%Read an input image
a=imread('C:\Users\nadeem\Desktop\palace.png');
%histogram processing
subplot(3,2,1);
imshow(a);
title('original image');
%converting to gray
subplot(3,2,3);
b=rgb2gray(a);
imshow(b);
title('grayscale image');
%equalisation of image
subplot(3,2,4);
c=histeq(b);
imshow(c);
title('equalised image');
subplot(3,2,5);
imhist(b);
title('histogram of grayscale image');
subplot(3,2,6);
imhist(c);
title('histogram of equalised image');
OUTPUT
Fig.1. Histogram Equalization with subplots
Fig.1 Original Image (Low contrast | Dark Image)
Fig.2 Corresponding Grayscale Image
Fig.4 Corresponding Histogram plot of grayscale image
Fig.3 Histogram Equalized image
Fig.5 Corresponding Histogram plot of Equalized image
HISTOGRAM EQUALIZATION USING COLOR IMAGE
clc;
clear all;
close all;
%Read Color Image
a=imread('C:\Users\natheem\Desktop\images\monky.jpg');
%histogram processing
subplot(3,3,1);
imshow(a);
title('Original image');
%converting to gray
subplot(3,3,2);
b=rgb2gray(a);
imshow(b);
title('Grayscale image');
%equalisation of image
subplot(3,3,3);;
c=histeq(b);
imshow(c);
title('Equalised image');
subplot(3,3,5);
imhist(b);
title('Histogram of grayscale image');
subplot(3,3,6);
imhist(c);
title('Histogram of equalised image');
RESULT
OUTPUT WITH SEPARATE FIGURE
Fig.1. original Image
Fig.2.Grayscale image
Fig.3.Histogram equalized image
Fig.4.Histogram plot of grayscale image
Fig.5. Histogram plot of Equalized image
Conclusion
Histogram equalization is a direct image processing technique often used to achieve better quality images in black and white color balances in medical applications such as X-rays, MRIs, and CT scans. All these images require high definition and contrast of colors to determine the pathology that is being experiential and reach a diagnosis. Though, in some type of images histogram equalization can show noise hidden in the image after the processing is done.
Comments
Post a Comment