Skip to content

Instantly share code, notes, and snippets.

@mirsahib
Created October 26, 2018 04:49
Show Gist options
  • Save mirsahib/100cb171723081f552e3119b1b25389e to your computer and use it in GitHub Desktop.
Save mirsahib/100cb171723081f552e3119b1b25389e to your computer and use it in GitHub Desktop.
function brightness()
I = imread('AtlasMercury.tiff');
J=I;
%increase brightness
[r,c,l] = size(I);
g = 100;%transformed value
for i=1:l
for j =1:r
for k=1:c
if(I(j,k,i)+g<256)
I(j,k,i)=I(j,k,i)+g;
else
I(j,k,i)=255;
end
end
end
end
%decrease brightness
for i=1:l
for j =1:r
for k=1:c
if(I(j,k,i)-g<0)
I(j,k,i)=0;
else
I(j,k,i)=I(j,k,i)-g;
end
end
end
end
%imshow(J);
%imshow(I);
subplot(1,2,1)
imhist(J);
title('Original');
subplot(1,2,2)
imhist(I);
title('Modified');
saveas(gcf,'histogram.jpg');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment