ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/uniq_rgb.cal
Revision: 1.1
Committed: Thu Aug 28 16:37:04 2014 UTC (9 years, 8 months ago) by greg
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2P1
Log Message:
Added file for computing unique, non-neutral color palette

File Contents

# Content
1 { RCSid $Id$ }
2 {
3 Generate unique (distinguishable) RGB colors.
4
5 8/28/2014 G. Ward
6
7 Usage:
8 cnt `rcalc -n -f xyz_srgb.cal -f cieluv.cal \
9 -f uniq_rgb.cal -e '$1=Nu;$2=Nv'` \
10 | rcalc -f xyz_srgb.cal -f cieluv.cal -f uniq_rgb.cal \
11 -e '$1=Runq;$2=Gunq;$3=Bunq'
12 }
13 Umin : up(X(0,1,0),Y(0,1,0),Z(0,1,0));
14 Umax : up(X(1,0,0),Y(1,0,0),Z(1,0,0));
15 Vmin : vp(X(0,0,1),Y(0,0,1),Z(0,0,1));
16 Vmax : vp(X(0,1,0),Y(0,1,0),Z(0,1,0));
17
18 Yref : Y(0,0,1);
19
20 NDstep : 1/(13/7*Ls(Yref));
21
22 Nu : ceil((Umax - Umin)/NDstep);
23 Nv : ceil((Vmax - Vmin)/NDstep);
24
25 x_uv(u,v) : 9*u/(6*u - 16*v + 12);
26 y_uv(u,v) : 4*v/(6*u - 16*v + 12);
27
28 btwn(a,x,b) : if(x-a,b-x,-1);
29 and(a,b) : if(a, b, -1);
30 max(a,b) : if(a-b, a, b);
31
32 NeuMargin : 2*NDstep;
33
34 uneu : up(Yref,Yref,Yref);
35 vneu : vp(Yref,Yref,Yref);
36
37 utst = $1*NDstep + Umin;
38 vtst = $2*NDstep + Vmin;
39
40 Ytst : Yref;
41 Xtst = 9/4*utst/vtst * Ytst;
42 Ztst = (1/y_uv(utst,vtst) - 1)*Ytst - Xtst;
43
44 Rtst = R(Xtst,Ytst,Ztst);
45 Gtst = G(Xtst,Ytst,Ztst);
46 Btst = B(Xtst,Ytst,Ztst);
47
48 dist2neu = (utst-uneu)*(utst-uneu) + (vtst-vneu)*(vtst-vneu);
49
50 cond = and(btwn(0,Rtst,1), and(btwn(0,Gtst,1), and(btwn(0,Btst,1),
51 dist2neu-NeuMargin*NeuMargin)));
52
53 sca = 1/max(Rtst,max(Gtst,Btst));
54 Runq = sca*Rtst;
55 Gunq = sca*Gtst;
56 Bunq = sca*Btst;