-
Notifications
You must be signed in to change notification settings - Fork 1
/
process5.m
150 lines (143 loc) · 2.9 KB
/
process5.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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
function [saliency,smooth]= process5(Vf,Vt1,Vt2)
%%
%Vf (red) changing background
%create an empty matrix (256*256) representing the first channel of the
%image. X and y must be lower than 256
Vw= cat(3, zeros(256));
%Square image 256x256
x=length(Vf(:,1));
y=length(Vf(1,:));
%Assign the content of the selected sequence Vf (FLAIR) to the new variable
%Vw expanding its size to (256*256)
for i = 1:x
for j = 1:y
Vw(i,j)=Vf(i,j);
Vw(i,j)=Vf(i,j);
Vw(i,j)=Vf(i,j);
end
end
%
%Intensity of background
cont=0;
mediaF=0;
for i = 1:x
for j = 1:y
if(Vw(i,j)>0)
%I don't consider the black pixels because they don't contribute
%to the mean.
mediaF=mediaF+Vw(i,j);
cont=cont+1;
end
end
end
%If there isn't any pixels of the image, my mean value is equal to zero
if(cont==0)
mediaF=0;
else
mediaF=mediaF/cont;
end
%
%Change background color if mean value is not zero
%Every pixels previous equal to zero now assume the mean value of the image
for i = 1:256
for j = 1:256
if(Vw(i,j)==0)
Vw(i,j)=mediaF;
end
end
end
VbgF=Vw;
%%
%Vt1 (green) changing background
for i = 1:256
for j = 1:256
if((i<x)&&(j<y))
Vw(i,j)=Vt1(i,j);
Vw(i,j)=Vt1(i,j);
Vw(i,j)=Vt1(i,j);
else
Vw(i,j)=0;
Vw(i,j)=0;
Vw(i,j)=0;
end
end
end
%
%Intensity of background
cont=0;
mediaT1=0;
for i = 1:x
for j = 1:y
if(Vw(i,j)>0)
mediaT1=mediaT1+Vw(i,j);
cont=cont+1;
end
end
end
if(cont==0)
mediaT1=0;
else
mediaT1=mediaT1/cont;
end
%
%Change background color
for i = 1:256
for j = 1:256
if(Vw(i,j)==0)
Vw(i,j)=mediaT1;
end
end
end
VbgT1=Vw;
%%
%Vt2 (blue) changing background
for i = 1:256
for j = 1:256
if((i<x)&&(j<y))
Vw(i,j)=Vt2(i,j);
Vw(i,j)=Vt2(i,j);
Vw(i,j)=Vt2(i,j);
else
Vw(i,j)=0;
Vw(i,j)=0;
Vw(i,j)=0;
end
end
end
%
%Intensity of background
cont=0;
mediaT2=0;
for i = 1:x
for j = 1:y
if(Vw(i,j)>0)
mediaT2=mediaT2+Vw(i,j);
cont=cont+1;
end
end
end
if(cont==0)
mediaT2=0;
else
mediaT2=mediaT2/cont;
end
%
%Change background color
for i = 1:256
for j = 1:256
if(Vw(i,j)==0)
Vw(i,j)=mediaT2;
end
end
end
VbgT2=Vw;
%%
VRed = cat(3, VbgF, zeros(256), zeros(256) );
VGreen = cat(3, zeros(256), VbgT2, zeros(256) );
VBlue = cat(3, zeros(256), zeros(256), VbgT1 );
Vbg=VRed+VGreen+VBlue;
Vbg=rgb2lab(Vbg);
%%
%pass to the next function the updated sequences
[saliency,smooth] = process6(Vbg,x,y);
end