image thumbnail
from Image Equalization by Gholamreza (Shahab) Anbarjafari
Here there are some equalization methods.

Some_Equalization.m
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This code has been written in 2008 by me, Gholamreza Anbarjafari        %
% (Shahab). You can use this code for any research and academic purposes  %
% as far as you refer to the following work:                              %
% Hasan Demirel and Gholamreza Anbarjafari, "HSI Based Colour Image       %
% Equalization using Iterative nth Root and nth Power", 5th International %
% Conference on Electrical and Computer Systems (EECS08), Nov 27-28,      %
% 2008, Lefke, North Cyprus.                                              %
%                                                                         %
% Feel free to contact us for any furthur information:                    %
%  {hasan.demirel, shahab.jafari}@emu.edu.tr                              %
%   http://faraday.ee.emu.edu.tr/shahab                                   %
%   http://faraday.ee.emu.edu.tr/hdemirel                                 %
%   (c) Demirel and Anbarjafari -2008                                     %
%                                                                         %
% The iterative proposed method for equalization is based on achieving a  %
% normalized image with mean of 0.5 in R, G and B channels.               %
% one can easily calculate the PSNR using the calcpsnr commend avaiable in%
% this address: http://www.mathworks.com/matlabcentral/fileexchange/22241 %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clc
clear all
i=imread('illu3_1.jpg');
id=i;
id=im2double(id);
[h,s,v]=rgb2hsv(id);
v=im2double(v);
m=mean(mean(v));
while (abs(m-0.5)>0.1)
    if m<0.5
        v=(v).^(1-m);
    else
        v=v.^(1/(1-m));
    end
    m=mean(mean(v));
end
ID(:,:,1)=h;ID(:,:,2)=s;ID(:,:,3)=v;
idhsv=hsv2rgb(ID);

id1=im2double(imread('illu3.jpg'));

clear i;
i=uint8(idhsv*255);
id_cool=idhsv;
idr=idhsv(:,:,1);idg=idhsv(:,:,2);idb=idhsv(:,:,3);
m=mean(mean(idr));
while (abs(m-0.5)>0.1)
    if m<0.5
        idr=(idr).^(1-m);
    else
        idr=idr.^(1/(1-m));
    end
    m=mean(mean(idr));
end
m=mean(mean(idg));
while (abs(m-0.5)>0.1)
    if m<0.5
        idg=(idg).^(1-m);
    else
        idg=idg.^(1/(1-m));
    end
    m=mean(mean(idg));
end
m=mean(mean(idb));
while (abs(m-0.5)>0.1)
    if m<0.5
        idb=(idb).^(1-m);
    else
        idb=idb.^(1/(1-m));
    end
    m=mean(mean(idb));
end


idr_cool=id_cool(:,:,1);idg_cool=id_cool(:,:,2);idb_cool=id_cool(:,:,3);
cnt1=1;mm=mean(mean(idr_cool));
while (abs(mm-0.5)>0.00009)
    idr_cool=idr_cool.^(log(0.5)/log(mm));
    mm=mean(mean(idr_cool));
end
mm=mean(mean(idg_cool));
while (abs(mm-0.5)>0.00009)
    idg_cool=idg_cool.^(log(0.5)/log(mm));
    mm=mean(mean(idg_cool));
end
mm=mean(mean(idb_cool));
while (abs(mm-0.5)>0.00009)
    idb_cool=idb_cool.^(log(0.5)/log(mm));
    mm=mean(mean(idb_cool));
end

ieqr=im2double(histeq(i(:,:,1)));ieqg=im2double(histeq(i(:,:,2)));
ieqb=im2double(histeq(i(:,:,3)));
id(:,:,1)=idr;id(:,:,2)=idg;id(:,:,3)=idb;
id_cool(:,:,1)=idr_cool;id_cool(:,:,2)=idg_cool;id_cool(:,:,3)=idb_cool;
ieq(:,:,1)=ieqr;ieq(:,:,2)=ieqg;ieq(:,:,3)=ieqb;

figure;subplot(221);imshow(id1);xlabel('Original');
subplot(222);imshow(uint8(id*255));xlabel('Iterative Root _ Power');
subplot(223);imshow(uint8(id_cool*255));
xlabel('Iterative Logarithmic Root _ Power');
subplot(224);imshow(uint8(ieq*255));;xlabel('HISTEQ')

Contact us at files@mathworks.com