How do I reduce image brightness and increase image contrast?

I have images with small ROI that are overexposed. Is there any way I can run this image editing as part of the code?

Answers (1)

You should map it with a transform.
I2 = histeq(I);
imshow(I2) %contrast enhancing
to reduce brightness:
I=double(I);
a=min(min(I));
b=max(max(I));
t=150;
[m1,m2]=size(I);
I2=zeros(m1,m2);
for i=1:m1
for j=1:m2
I2(i,j)=(t/(b-a))*(I(i,j)-a);
end
end
I2=uint8(I2);
imshow(I2);
as you decrease 't', the output image will become darker.

Asked:

on 22 Jul 2016

Commented:

on 9 Mar 2020

Community Treasure Hunt

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

Start Hunting!