-
Notifications
You must be signed in to change notification settings - Fork 0
/
transforms.m
44 lines (36 loc) · 1.04 KB
/
transforms.m
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
41
42
43
44
% Performs Logrithmic and Exponential Transforms on an Image
[fname, pthname]=uigetfile('*.jpg;*.png;*.tif;*.bmp','Select the Asset Image'); %select image
img = imread([pthname fname]);
[row, col, wid] = size(img);
if(wid==3)
img = rgb2gray(img); % convert to gray scale if it is color image
end
c = 2;
% Log transformation
L = img;
for i=1:size(img,1)
for j=1:size(img,2)
in = double(img(i,j));
L(i,j) = c.*log10(in);
end
end
% Exponantial transformation
E = img;
for i=1:size(img,1)
for j=1:size(img,2)
in = double(L(i,j));
E(i,j) = exp(in);
end
end
% convert to 8-bit
logT = (L/(max(L(:))))*255;
expT = (E/(max(E(:))))*255;
figure
ax1 = subplot(1,1,1); imshow(img),title('Original');
figure
% ax2 = subplot(1,1,1); imshow(logT),title('Log Transformed');
ax2 = subplot(1,1,1); imshow(L),title('Log Transformed');
figure
% ax3 = subplot(1,1,1); imshow(expT),title('Exponential of Log Transformed');
ax3 = subplot(1,1,1); imshow(E),title('Exponential of Log Transformed');
linkaxes([ax1 ax2 ax3],'xy');