-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContrast Transformation
More file actions
40 lines (28 loc) · 872 Bytes
/
Contrast Transformation
File metadata and controls
40 lines (28 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
clc; %clear cmd window
clear all; %clear memory
%f=[23 32 21 24;23 255 200 0;1 99 92 45;21 56 73 85]
f=imread('pout.tif'); %read image in an matrix
[row,col]=size(f) % get size of matrix
r1=50; %till this original image are supposed to be dark
r2=200; %from 51 to 170 it is supoosed to be bright
%value of slopes
alpha=0;
beta=1.5;
gamma=0.3;
% calculating coressponding values of r1 and r2
s1=alpha*r1;
s2=beta*(r2-r1)+r1;
for x=1:1:row
for y=1:1:col
if 0<=f(x,y) && f(x,y)<=r1
g(x,y)=alpha*f(x,y);
elseif r1<=f(x,y) && f(x,y)<=r2
g(x,y)=beta*(f(x,y)-r1)+s1;
else
g(x,y)=gamma*(f(x,y)-r2)+s2;
end
end
end
%g
figure(1), imshow(f), title('original image') %display of matrix as img
figure(2), imshow(g), title('Contrasted image')