ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/uniq_rgb.cal
Revision: 1.2
Committed: Mon Jun 10 13:56:52 2019 UTC (4 years, 11 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R3, HEAD
Changes since 1.1: +2 -3 lines
Log Message:
Added max() and min() as .cal library functions

File Contents

# Content
1 { RCSid $Id: uniq_rgb.cal,v 1.1 2014/08/28 16:37:04 greg Exp $ }
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
31 NeuMargin : 2*NDstep;
32
33 uneu : up(Yref,Yref,Yref);
34 vneu : vp(Yref,Yref,Yref);
35
36 utst = $1*NDstep + Umin;
37 vtst = $2*NDstep + Vmin;
38
39 Ytst : Yref;
40 Xtst = 9/4*utst/vtst * Ytst;
41 Ztst = (1/y_uv(utst,vtst) - 1)*Ytst - Xtst;
42
43 Rtst = R(Xtst,Ytst,Ztst);
44 Gtst = G(Xtst,Ytst,Ztst);
45 Btst = B(Xtst,Ytst,Ztst);
46
47 dist2neu = (utst-uneu)*(utst-uneu) + (vtst-vneu)*(vtst-vneu);
48
49 cond = and(btwn(0,Rtst,1), and(btwn(0,Gtst,1), and(btwn(0,Btst,1),
50 dist2neu-NeuMargin*NeuMargin)));
51
52 sca = 1/max(Rtst,Gtst,Btst);
53 Runq = sca*Rtst;
54 Gunq = sca*Gtst;
55 Bunq = sca*Btst;