SUNY Geneseo Department of Mathematics
Friday, April 10
Math 230 02
Spring 2015
Prof. Doug Baldwin
for each source pixel
if R,G,B intensities in range for “green” screen
copy background image pixel to output
else
copy source pixel to output
&
operator>> A = rand( 4 )
A =
0.8147 0.6324 0.9575 0.9572
0.9058 0.0975 0.9649 0.4854
0.1270 0.2785 0.1576 0.8003
0.9134 0.5469 0.9706 0.1419
>> low = 0.25;
>> hi = 0.75;
>> low < A
ans =
1 1 1 1
1 0 1 1
0 1 0 1
1 1 1 0
>> A1 = ans
A1 =
1 1 1 1
1 0 1 1
0 1 0 1
1 1 1 0
>> A2 = A < hi
A2 =
0 1 0 0
0 1 0 1
1 1 1 0
0 1 0 1
>> A1+A2
ans =
1 2 1 1
1 1 1 2
1 2 1 1
1 2 1 1
>> low < A & A < hi
ans =
0 1 0 0
0 0 0 1
0 1 0 0
0 1 0 0
>> A1 & A2
ans =
0 1 0 0
0 0 0 1
0 1 0 0
0 1 0 0
>> A1 .* A2
ans =
0 1 0 0
0 0 0 1
0 1 0 0
0 1 0 0
>> A
A =
0.8147 0.6324 0.9575 0.9572
0.9058 0.0975 0.9649 0.4854
0.1270 0.2785 0.1576 0.8003
0.9134 0.5469 0.9706 0.1419
>> mask = low < A & A < hi
mask =
0 1 0 0
0 0 0 1
0 1 0 0
0 1 0 0
>> A .* mask
ans =
0 0.6324 0 0
0 0 0 0.4854
0 0.2785 0 0
0 0.5469 0 0
>> A( mask )
ans =
0.6324
0.2785
0.5469
0.4854
>> out = zeros(4)
out =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
>> A
A =
0.8147 0.6324 0.9575 0.9572
0.9058 0.0975 0.9649 0.4854
0.1270 0.2785 0.1576 0.8003
0.9134 0.5469 0.9706 0.1419
>> out(mask) = A(mask)
out =
0 0.6324 0 0
0 0 0 0.4854
0 0.2785 0 0
0 0.5469 0 0