Last active
May 8, 2016 21:32
-
-
Save agaikwad123/d1324f96cf703598b99c956238d17bda to your computer and use it in GitHub Desktop.
Study of Gray level transformations on an image using MATLAB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a= input (Enter the path of the image:); % accept image path from user | |
b= imread (a); % read the image | |
[x,y]=size (b); % store the image in matrix form | |
d=max (max (b)); % find he max value in the matrix | |
for i=1:x | |
for j=1:y | |
if(b(i,j))<=50 | |
f(i,j)= 0.2*(b(i,j)); | |
elseif (50<=(b(i,j))<=150) | |
f(i,j)=2*(b(i,j)); %formula for contrast stretching; | |
elseif 150<=b(i,j)<=d | |
f(i,j)= 0.3*(b(i,j)); | |
end | |
end | |
end | |
figure | |
subplot(1,2,1) | |
imshow(b) % show original image | |
title(Original image) | |
subplot(1,2,2) | |
imshow(f) % show transformed image | |
title(Contrast Stretching) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Log Transformation | |
clc; clear all; close all; | |
a= input (Enter the path of the image:); % accept image path from user | |
[x,y]=size (b); | |
b= imread (a); % read the image | |
e=im2double(b); | |
for i=1:x | |
for j=1:y | |
S(i,j)= 1*(1+log10(e(i,j))); % formula for log transformation | |
end | |
end | |
figure | |
subplot(1,2,1) | |
imshow(b) % show original image | |
title(Original image;) | |
subplot(1,2,2) | |
imshow(S) %Show log transformed image | |
title(Log transformed Image&) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Power law transformation | |
clc; clear all; close all; | |
a= input (Enter the path of the image:); % accept image path from user | |
b= imread (a); % read the image | |
[x,y]=size (b); % store the image in matrix form | |
d=max (max (b)); % find he max value in the matrix | |
r=input(Enter value of r:) | |
for i= 1:x | |
for j= 1:y | |
a= input (Enter the path of the image:); % accept image path from user | |
b= imread (a); % read the image | |
[x,y]=size (b); % store the image in matrix form | |
d=max (max (b)); % find he max value in the matrix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1] Negative Transform | |
clc; clear all; close all; | |
% Negative transformation | |
a= input (Enter the path of the image:); % accept image path from user | |
b= imread (a); % read the image | |
[x,y]=size (b); % store the image in matrix form | |
d=max (max (b)); % find he max value in the matrix | |
for i=1:x | |
for j=1:y | |
fn(i,j)=d-b(i,j); %formula for negative transform of image | |
end | |
end | |
figure | |
subplot(1,2,1) | |
imshow(b) ; % show original image | |
title(Original image) | |
subplot(1,2,2) | |
imshow(fn) % show –ve transform of image | |
title(Negative image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment