# Right Shifting the Histogram (Histogram Shifting) or Making the Image Brighter Using MATLAB

Yes making your histogram to shift right  & making your image more bright are one & the same thing. Very easy to perform & you just need to apply some very basic arithmetic operation on the image. The operations could be either addition or multiplication with a constant greater than 1.

For this article, we have taken a 640x640 grayscale image which is kept in the Current Working Directory. After opening it in MATLAB we will perform the further operations.

Histogram Left Shifting by subtraction of a constant:
MATLAB Code & Explanation:
%Suppose we are adding a constant value of 20 from each element of the grayscale image
%In the results it will be clearly visible that the image has become more bright & the
%histogram is shifted to right side, & no values in the histogram for the value range 0-20
% i.e., at first 20 values in the histogram is vanished.

% if the image is not in the current working directory you need to specify the full path.

imshow(x);
%for showing the original image

figure,imhist(x)
%for showing the histogram of original image

n=x+20;
%performing the arithmetic operation on each element of the image  & storing the result in new variable

figure,imhist(n)
%for showing the operated image

figure,imshow(n)
%for showing the histogram of operated image

Results of The above MATLAB code of Left Shifting the Histogram using subraction Original Unprocessed Image Histogram of Original Image Image After the arithmetic Operation (More Darker Than Original) The right shifted histogram of the image after operation

Histogram Left Shifting By multiplication of a constant greater than 1 (>1):
MATLAB Code & Explanation:

% if the image is not in the current working directory you need to specify the full path.

imshow(x);
%for showing the original image

figure,imhist(x)
%for showing the histogram of original image

n=x*1.25;
%performing the arithmetic operation on each element of the image  & storing the result in new variable

figure,imhist(n)
%for showing the operated image

figure,imshow(n)
%for showing the histogram of operated image

Results of The above MATLAB code of Left Shifting the Histogram using multiplication Original Unprocessed Image Histogram of Original Image Image After the Multiplication with a constant greater than 1 Histogram of Original Image
In this case the histogram is not seeming to be shifted but it is, as 0x(anything)=0 only the values with pixel value '0' is not changed.

In both the cases, the right shifted histogram is roughly the shape of the original one.

NOTE:  If the constant which is being added or multiplied is very large you are going to obtain a nearly saturated image or a histogram very much shifted to the right