summaryrefslogtreecommitdiff
path: root/3176/CH6/EX6.9/Ex6_9.sce
blob: d026191623d44ae4bcee62d48018a233a35a1e6c (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//Ex6_9 : 
//Tonal Transformations.

// Version : Scilab 5.4.1
// Operating System : Window-xp, Window-7
//Toolbox: Image Processing Design 8.3.1-1
//Toolbox: SIVP 0.5.3.1-2
//Reference book name : Digital Image Processing
//book author: Rafael C. Gonzalez and Richard E. Woods

clc;
close;
clear;
xdel(winsid())//to close all currently open figure(s).

////////////////// Tonal Correction for the Flat Image  ////////////////////////
Color=imread("Ex6_9_1.tif");
Color=imresize(Color,0.5);
[nr nc]=size(Color);
figure,ShowColorImage(Color,'Gray Image');
title('Original Image');
D=0:256;
D0=155;// Cut-off Number
n=2;  // Order of Butter Wirth Approximation
H1 = 1-ones(1,1)./(1+(D./D0).^(2*n));  // Transfer Function (Design from the Butterworth Approximation)
figure,plot(H1);
title('RGB Intensity Transformation Function');
Slice_Image=[];
for i=1:nr 
    for j=1:nc                   
           Slice_Image(i,j,1)=H1(uint16(Color(i,j,1))+1);
           Slice_Image(i,j,2)=H1(uint16(Color(i,j,2))+1);
           Slice_Image(i,j,3)=H1(uint16(Color(i,j,3))+1);            
     end     
end
ShowColorImage(Slice_Image,'RGB Image');
title('Tonal Corrected image');

////////////////// Tonal Correction for the Light Image  ////////////////////////
Color=imread("Ex6_9_2.tif");
Color=imresize(Color,0.5);
[nr nc]=size(Color);
figure,ShowColorImage(Color,'Gray Image');
title('Original Image');
D=0:1/256:1;
H2=1*D^3.0;  // Transfer Function (Design from the Gamma Funcetion).
figure,plot(H2);
title('RGB Intensity Transformation Function');
Slice_Image=[];
for i=1:nr   
    for j=1:nc                   
           Slice_Image(i,j,1)=H2(uint16(Color(i,j,1))+1);
           Slice_Image(i,j,2)=H2(uint16(Color(i,j,2))+1);
           Slice_Image(i,j,3)=H2(uint16(Color(i,j,3))+1);            
     end     
end
ShowColorImage(Slice_Image,'RGB Image');
title('Tonal Corrected image');

////////////////// Tonal Correction for the Dark Image  ////////////////////////
Color=imread("Ex6_9_3.tif");
Color=imresize(Color,0.5);
[nr nc]=size(Color);
figure,ShowColorImage(Color,'Gray Image');
title('Original Image');
D=0:1/256:1;
H3=1*D^0.35;
figure,plot(H3);
title('RGB Intensity Transformation Function');
Slice_Image=[];
for i=1:nr   
    for j=1:nc                   
           Slice_Image(i,j,1)=H3(uint16(Color(i,j,1))+1);
           Slice_Image(i,j,2)=H3(uint16(Color(i,j,2))+1);
           Slice_Image(i,j,3)=H3(uint16(Color(i,j,3))+1);            
     end     
end
ShowColorImage(Slice_Image,'RGB Image');
title('Tonal Corrected image');