Colour Image Contrast Enhancement by Histogram Equalization

A colour image Enhancement by the histogram equalization process is as same as a grayscale image enhancement by histogram equalization except that colour space conversion technique included.

The input colour image has R (Red),G (Green) and B (Blue) components which forms rectangular or cube coordinate colour space. When doing histogram equalization on the input image, It has to apply histogram equalization to each components RGB colour space consequently, the enhanced image object's original colour will vary.

The HSV colour space has H (Hue),S (Saturation) and V (Value) components which forms circular or spherical coordinate colour space. When doing histogram equalization on the HSV colour space, It has to apply histogram equalization to only V component of HSV colour space and the resultant enhanced image object's original colour is preserved.


Test Image 1 - dining table

dining

Test Image 1 - Histogram of original and Enhanced image

dining

 


Matlab programming - Colour Image Contrast Enhancement by Histogram Equalization

 
%color image global histogram equalization
function cghisteq

clc; clear all;
close all;

%read a color image from specified path from current working directory
fname= 'images/butterfly-flower.jpg';
[im,map] = imread(fname);
maxI= 255;

%convert the image rgb to hsv colour space
cim=rgb2hsv(im);

%extract v (value) component from hsv space
imv =cim(:,:,3);
imv= round(imv.*maxI);

%find bins (number of intensity level) for the input image
X0 = min(imv(:));
XL  =max(imv(:));
bins=X0:XL;

%X0=0; XL=maxI;
%bins=X0:XL;

%find histogram count for the input image with respective bins
hc=histc(imv(:),bins);
nhc = hc / sum(hc) ;
chc = cumsum(nhc);

%transfer function of  image enhancement
T = X0 + (XL-X0).*chc;
%apply transfer function on input image to get enhanced image
eimv=T(imv+1-X0);

%append enhanced v component with hsv colour
cim(:,:,3) = eimv./maxI;

%convert hsv to rgb colour space
eim=hsv2rgb(cim);

figure;subplot(2,1,1),bar(0:255,histc(imv(:),0:255));
title('Input image :butterfly-flower');
subplot(2,1,2),bar(0:255,histc(eimv(:),0:255)); 
title('Constrast Enhanced image');

figure;subplot(1,2,1),imshow(im,map);
title('Input image :butterfly-flower');
subplot(1,2,2),imshow(eim,map); 
title('Constrast Enhanced image');


Test Image 2 - butterfly-flower

butterfly-flower

Test Image 2 - Histogram of respective original and Enhanced image

butterfly-flower

 

Comments

  1. Good day

    Can you send me the paper that this software is based of.

    Regards
    Rivania
    rivaniamaharaj@gmail.com

    ReplyDelete

Post a Comment

Popular posts from this blog

Image Segmentation - K-means Clustering

Adaptive Median Filter for Image Corrupted by Salt and Pepper Noise

Genetic Algorithm for Centroid Selection on Kmeans Image Segmentation