How can i correct brightness of a monochrome image using arithmetic operations?

8 views (last 30 days)
Initially i started by following this link and everything went fine. Now, I can't make a function which takes the following as arguments:
  • A monochrome image
  • Brightness percentage
  • A parameter which indicates the required correction(brighten, dark)
I was thinking if I should implement linear or non-linear operation on the image but don't know how.
How can that be done?

Answers (3)

Image Analyst
Image Analyst on 18 Nov 2018
Histogram equalization is lousy - don't use that. It's pretty much just a mathematical curiousity and should not be used in practice even though everyone says to use it, until they realize it's no good.
To adjust brightness, you can add an offset to the image, or you can multiply the image by some factor, or both multiply and add which is the most general situation. Depends on what you want to achieve. All of those methods change the contrast of the image as well as the brightness. You can't change one without the other.

Kamil Hassaan
Kamil Hassaan on 19 Nov 2018
This is what I did. I made a script file and a function file. Workde like a charm.
prompt = 'Press 3 for problem 3 : ';
prob = input(prompt);
if prob == 3
i1 = imread('Child_1.png');
prompt = 'Value of darkness : ';
dark = input(prompt);
prompt = 'Enter small D for darkness : ';
D = input(prompt, 's');
afterDark = problem3(i1, dark, D);
i2 = imread('Child_2.png');
prompt = 'Value of brightness : ';
bright = input(prompt);
prompt = 'Enter small B for brightness : ';
B = input(prompt, 's');
afterBright = problem3(i1, bright, B);
subplot(2,2,1), imshow(i1), title('Before dark filter');
subplot(2,2,2), imshow(i2), title('Before bright filter')
subplot(2,2,3), imshow(afterDark), title('Dark');
subplot(2,2,4), imshow(afterBright), title('Bright')
function func = problem3(image, val, bod)
if bod == 'd'
func = imdivide(image, val);
elseif bod == 'b'
func = imadd(image, val);

DGM on 20 Jun 2022
For basic brightness/contrast controls, see this demo.
For other ways of adjusting "brightness", see:
The takeaway here is that 'brightness' and 'contrast' are not necessarily independent. Addition does not influence contrast unless clipping occurs. Multiplication without offset will simultaneously change brightness and contrast to the same degree. The aforementioned demo is similar to simple adjustment tools as found in image editors.

Community Treasure Hunt

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

Start Hunting!