-
Notifications
You must be signed in to change notification settings - Fork 0
/
getchan.m
94 lines (72 loc) · 2.64 KB
/
getchan.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
function chan = getchan(imgs,channel,param)
chan = {};
% iterate over center scales
for scaleI = 1 : length(imgs)
img = imgs{scaleI};
if ( channel == 'I' )
chan{end+1} = squeeze( mean(img,3) );
elseif ( channel == 'C' )
if ( size(img,3) == 3 )
lum = squeeze( mean(img,3) ) + 0.01;
chan{end+1} = squeeze(abs(img(:,:,3,:) - min( img(:,:,1,:) , img(:,:,2,:)) )) ./ lum; % b - y (r,g)
chan{end+1} = squeeze(abs(img(:,:,1,:) - img(:,:,2,:))) ./ lum; % r - g
end
elseif ( channel == 'D' )
if ( size(img,3) == 3 )
map = img;
for fr = 1 : size(img,4)
map(:,:,:,fr) = rgb2dkl( map(:,:,:,fr) );
end
for i = 1 : 3
chan{end+1} = squeeze( map(:,:,i,:) );
end
end
elseif ( channel == 'O' )
img = squeeze( mean(img,3) );
for angi = 1 : param.nGaborAngles
map = img;
for fr = 1 : size(img,3)
f0 = myconv2(img(:,:,fr),param.gabor{angi}.g0);
f90 = myconv2(img(:,:,fr),param.gabor{angi}.g90);
map(:,:,fr) = attenuateBordersGBVS( abs(f0) + abs(f90) , 13 );
end
chan{end+1} = map;
end
elseif ( channel == 'F' ) % flicker channel with multiple image differences
Ts = param.flickmotionT;
for T = Ts,
d = abs( img(:,:,:,T+1:end) - img(:,:,:,1:end-T) );
d = squeeze(max( d , [] , 3 ));
z = repmat( 0 , [ size(img,1) size(img,2) size(img,4) ] );
z(:,:,T+1:end) = d;
z(:,:,1:T) = repmat( z(:,:,T+1) , [ 1 1 T ] );
chan{end+1} = z;
end
elseif ( channel == 'X' ) % flicker channel with only one frame difference (faster than (and equivalent to) F with param.flickerMotionT = [1] )
lum = squeeze( mean(img,3) );
f = abs( diff( lum , 1 , 3 ) );
z = repmat( 0 , [ size(img,1) size(img,2) size(img,4) ] );
z(:,:,2:end) = f;
z(:,:,1) = z(:,:,2);
chan{end+1} = z;
elseif ( channel == 'M' )
lum = squeeze( mean(img,3) );
nAngles = param.nMotionAngles;
maxAngle = 180 - (180/nAngles);
ang = linspace(0,maxAngle,nAngles);
lumshift = repmat( 0 , [ size(lum) numel(ang) ] );
for fri = 1 : size( lum , 3 )
for angi = 1 : numel( ang )
lumshift( : , : , fri , angi ) = shiftImage( lum(:,:,fri) , ang(angi) );
end
end
for T = param.flickmotionT,
for angi = 1 : numel(ang)
m = abs( lum(:,:,T+1:end) .* lumshift(:,:,1:end-T,angi) - lum(:,:,1:end-T) .* lumshift(:,:,T+1:end,angi) );
mm = repmat( 0 , size(lum) );
mm(:,:,T+1:end) = m;
chan{end+1} = mm;
end
end
end % end if chan == M
end % end scale loop