-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsa.m
53 lines (44 loc) · 1.45 KB
/
csa.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
% Conditional shiift algorithm
%-----------------------------------------------------------------------
function out=csa(a,mdset,siz)
%---------------------------------------------------------------------
% Inputs
%---------------------------------------------------------------------
XDR=a(:,:,1);
XDB=a(:,:,2);
XDG=a(:,:,3);
rxtp=XDR;
gxtp=XDG;
bxtp=XDB;
rm=[];
gm=[];
bm=[];
mdm=[];
%---------------------------------------------------------------------
for j=1:256
mdm(j)=maximum(mdset,j,1,siz);
rm(j)=maximum(XDR,j,2,siz);
gm(j)=maximum(XDG,j,2,siz);
bm(j)=maximum(XDB,j,2,siz);
if mdm(j)<=rm(j)
rxtp=shiftlr(rxtp,mdm(j),j);
else
rxtp=shiftrr(rxtp,mdm(j),j);
end
if mdm(j)<=gm(j)
gxtp=shiftlr(gxtp,mdm(j),j);
else
gxtp=shiftrr(gxtp,mdm(j),j);
end
if mdm(j)<=bm(j)
bxtp=shiftlr(bxtp,mdm(j),j);
else
bxtp=shiftrr(bxtp,mdm(j),j);
end
end
%-------------------------------------------------------------------------
% Output
%-----------------------------------------------------------------------
out=cat(3,rxtp,bxtp,gxtp);
%------------------------------------------------------------------------
end