adjust brightness of image

28 views (last 30 days)
Omar B.
Omar B. on 27 Oct 2021
Commented: Omar B. on 27 Oct 2021
What is the difference between adjust the brightness of image by order of gamma and by alpha?
Also, what is the difference between the above methods and adaptive histogram?

Accepted Answer

DGM
DGM on 27 Oct 2021
Edited: DGM on 27 Oct 2021
Consider the following examples. Note the changes to the image, the changes to the transfer function shape and endpoint locations, and the manner in which the histogram is transformed.
% present the test image unaltered
A = imread('tire.tif');
Ax = linspace(0,1,100);
subplot(2,2,1); imshow(A)
subplot(2,2,2); plot(linspace(0,1,100),Ax)
xlim([0 1]); ylim([0 1]); axis square
xlabel('in'); ylabel('out')
subplot(2,2,3:4); imhist(A)
Linear operations
% change input control points (lower white point)
% note the clipping
B = imadjust(A,[0 0.75],[0 1],1);
Bx = imadjust(Ax,[0 0.75],[0 1],1);
clf % just to reset web-view
subplot(2,2,1); imshow(B)
subplot(2,2,2); plot(linspace(0,1,100),Bx)
xlim([0 1]); ylim([0 1]); axis square
subplot(2,2,3:4); imhist(B)
% change output control points (raise black point)
B2 = imadjust(A,[0 1],[0.25 1],1);
B2x = imadjust(Ax,[0 1],[0.25 1],1);
clf % just to reset web-view
subplot(2,2,1); imshow(B2)
subplot(2,2,2); plot(linspace(0,1,100),B2x)
xlim([0 1]); ylim([0 1]); axis square
subplot(2,2,3:4); imhist(B2)
Changing control points (linear operations) result in a uniform stretching (and potential truncation) of the histogram.
Gamma adjustment
Gamma adjustment is a simple power function. White and black points don't move; rather, the intensity distribution is skewed toward one end or the other. Note the histogram.
% change gamma instead
% note that black and white don't move
C = imadjust(A,[0 1],[0 1],0.5);
Cx = imadjust(Ax,[0 1],[0 1],0.5);
clf % just to reset web-view
subplot(2,2,1); imshow(C)
subplot(2,2,2); plot(linspace(0,1,100),Cx)
xlim([0 1]); ylim([0 1]); axis square
subplot(2,2,3:4); imhist(C)
Alpha blending??
Alpha is a transparency component. You don't adjust brightness by adjusting alpha. In a compositing environment, you could adjust brightness by alpha blending it with a lighter image, but while MIMT tools can do this, nothing in base MATLAB or the Image Processing Toolbox has any meaningful support for alpha content or compositing. I'm going to assume that this is irrelevant to your needs if you're asking.
% compose image with a solid white field
% using a uniform alpha of 0.5
% THIS USES MIMT TOOLS (see File Exchange)
F = imblend(A,ones(size(A)),0.5,'normal');
Fx = imblend(Ax,ones(size(Ax)),0.5,'normal');
clf % just to reset web-view
subplot(2,2,1); imshow(F)
subplot(2,2,2); plot(linspace(0,1,100),Fx)
xlim([0 1]); ylim([0 1]); axis square
subplot(2,2,3:4); imhist(F)
As in the first example, the result is the same as shifting the control points (the blending is linear), though in practice, alpha is a map, not a scalar, and the background image isn't necessarily a solid field. As such, it should be obvious that using compositing or blending to merely adjust global brightness is an utter trivialization of a much more flexible process.
Adaptive Histogram EQ
Histogram equalization is an entirely different thing with entirely different uses. I'd recommend just reading the documentation for adapthisteq().
% change contrast using adapthisteq
E = adapthisteq(A);
clf % just to reset web-view
subplot(2,2,1); imshow(A)
subplot(2,2,2); imhist(A)
subplot(2,2,3); imshow(E)
subplot(2,2,4); imhist(E)
  1 Comment
Omar B.
Omar B. on 27 Oct 2021
Thank you very much for your explanation.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!