Image Contrast Enhancement by Histogram Equalization
A contrast enhancement of images by histogram equalization (HE) is very popular image processing technique widely used as preprocessing steps for medical and many other image and video processing applications.
HE performs its operation by remapping the gray levels of the image based on the cumulative probability distribution of the input gray levels
Algorithm steps Histogram Equalization
- set maxI=255, minI=0
- set nbins =255
- Read Input-Image, im
- hc <- histogram-count (im,nbins)
- prob <- (hc) / sum(hc)
- cprob <- cumlative-sum(prob)
- Tf <- minI + (maxI -minI) x cprob
- Eim = Tf(im)
- maxI - maximum intensity level , minI - maximum intensity level
- nbins - number of bins(level) for histograms count
- Tf - Intensity mapping transfer function
- im - Input Image
- Eim - Enhanced output Image
Matlab code for Image Histogram Equalization by Contrast Enhancement
%global histogram equalization
function ghisteq
clc; clear all;
close all;
% read a input image from file path
fname= 'images/butterfly.png';
[im,map] = imread(fname);
im= double(im);
%find minimum and maximum intensity value of the input image
X0 = min(im(:));
XL = max(im(:));
%generate bins from min to max intensity
bins=X0:XL;
%find histogram count hc for input image with respect to bins
hc=histc(im(:),bins);
% probability distribution or normalize histogram count of input image
nhc = hc / sum(hc) ;
%find normalized cumulative histogram or probability distribution
chc = cumsum(nhc);
%form histogram equalization mapping transfer function
T = X0 + (XL-X0).*chc;
T= uint8(round(T));
% apply mapping transfer on input image to get contrast enhanced image
eim = T(im+1);
figure;subplot(1,2,1),imshow(uint8(im),map);title('Input image :Butterfly');
subplot(1,2,2),imshow(eim,map); title('Constrast Enhanced image');
eim = T(im-X0+1);
ReplyDelete