function demoHS

im=imread('pout.tif');
 im=imread('cameraman.tif');

h_des = ones(1,256);
 h_des = 0:255;
% h_des = (0:255).^.5;
 h_des = (0:255).^.3;

im_0=histeq(im,h_des);
im_1=exact_histogram(im,h_des);

h=imhist(im);
h_0=imhist(im_0);
h_1=imhist(im_1);


% Original image
%--------------------------------------------------------------------------
figure(31); %('color',[1 1 1]) 
h_im=axes('units','normalized','position',[0.05 0.1 0.4 0.8]);
imshow(im)

h_h=axes('units','normalized','position',[0.55 0.1 0.4 0.8]);
bar(0:255,h,'b');
set(h_h,'xlim',[0 255],'FontSize',10,'FontWeight','bold')
set(get(h_h,'Title'),'String','Original Image','FontSize',10,'FontWeight','bold')

Ylim_ref=get(h_h,'ylim');

% Histogram equalization example and comparison
%==========================================================================

% Classical histogram equalization
%--------------------------------------------------------------------------
figure(32); %('color',[1 1 1]) 
h_im=axes('units','normalized','position',[0.05 0.1 0.4 0.8]);
imshow(im_0)

h_h=axes('units','normalized','position',[0.55 0.1 0.4 0.8]);
bar(0:255,h_0,'b');
set(h_h,'xlim',[0 255],'ylim',Ylim_ref,'FontSize',10,'FontWeight','bold')
set(get(h_h,'Title'),'String','Classical Histogram Equalization','FontSize',10,'FontWeight','bold')

% Exact histogram equalization
%--------------------------------------------------------------------------
figure(33); %('color',[1 1 1]) 
h_im=axes('units','normalized','position',[0.05 0.1 0.4 0.8]);
imshow(im_1)

h_h=axes('units','normalized','position',[0.55 0.1 0.4 0.8]);
bar(0:255,h_1,'b');
set(h_h,'xlim',[0 255],'ylim',Ylim_ref,'FontSize',10,'FontWeight','bold')
set(get(h_h,'Title'),'String','Exact Histogram Equalization','FontSize',10,'FontWeight','bold')
