Point operation in digital image processing -- histogram equalization

I. Theoretical Basis
1. Histogram equalization
2. Histogram specification
(there are many theoretical basis derivation, you can baidu yourself. Here only matlab implementation and histogram equalization and specification are given.)
II. matlab implementation
Histogram equalization:

%histogram equalization 
I=imread('pout.tif');
I=im2double(I);
%Image with increased contrast
I1=2*I-55/255;
subplot(4,4,1);
imshow(I1);
title('Increased contrast','FontSize',8);
subplot(4,4,2);
imhist(I1);
subplot(4,4,3);
imshow(histeq(I1));
title('Histogram equalization effect','FontSize',8);
subplot(4,4,4);
imhist(histeq(I1));
%Image with reduced contrast
I1=0.5*I+55/255;
subplot(4,4,5);
imshow(I1);
title('Less contrast','FontSize',8);
subplot(4,4,6);
imhist(I1);
subplot(4,4,7);
imshow(histeq(I1));
title('Histogram equalization effect','FontSize',8);
subplot(4,4,8);
imhist(histeq(I1));
%Image with linearly increased brightness
I1=I+55/255;
subplot(4,4,9);
imshow(I1);
title('Increase brightness','FontSize',8);
subplot(4,4,10);
imhist(I1);
subplot(4,4,11);
imshow(histeq(I1));
title('Histogram equalization effect','FontSize',8);
subplot(4,4,12);
imhist(histeq(I1));
%Image with linearly reduced brightness
I1=I-55/255;
subplot(4,4,13);
imshow(I1);
title('Reduce brightness','FontSize',8);
subplot(4,4,14);
imhist(I1);
subplot(4,4,15);
imshow(histeq(I1));
title('Histogram equalization effect','FontSize',8);
subplot(4,4,16);
imhist(histeq(I1));

Execution result:


From the above figure, we can find that the equalization of the same image can achieve almost the same effect under the condition of different brightness contrast, that is to say, histogram equalization can resist various transformations, so as to eliminate the appearance difference between different deformable bodies of the image. Moreover, it is found that the image after equalization has higher contrast than the original image, which shows that histogram equalization has the effect of adaptive contrast enhancement.

Histogram specification

%Histogram specification
I=imread('pout.tif');
I1=imread('coins.png');
I2=imread('circuit.tif');
%Calculate histogram
[hgram1,x1]=imhist(I1);
[hgram2,x2]=imhist(I2);
%Perform histogram equalization
J1=histeq(I,hgram1);
J2=histeq(I,hgram2);
%Mapping
figure;
subplot(2,3,1);
imshow(I);title('Original image');
subplot(2,3,2);
imshow(I1);title('Standard figure 1');
subplot(2,3,3);
imshow(I2);title('Standard figure 2');
subplot(2,3,5);
imshow(J1);title('Specify to 1');
subplot(2,3,6);
imshow(J2);title('Specify to 2');
%Draw histograms
figure;
subplot(2,3,1);
imhist(I);title('Original graph');
subplot(2,3,2);
imhist(I1);title('Standard figure 1');
subplot(2,3,3);
imhist(I2);title('Standard figure 2');
subplot(2,3,5);
imhist(J1);title('Specify to 1');
subplot(2,3,6);
imhist(J2);title('Specify to 2');

Execution result:


It is found that the histogram of the normalized image is similar to the histogram of the original image. The essence of histogram normalization is a kind of fitting process. Therefore, the histogram obtained by transformation will not be completely consistent with the histogram of the standard target image. However, only similar fitting still makes the normalized image similar to the standard image in brightness and contrast, which is also the histogram The purpose of the specification.

Tags: MATLAB less

Posted on Thu, 28 Nov 2019 09:03:28 -0800 by yogadt