I’m developing new command codes like rgb2ryb and ryb2rgb to expand on some filters and I’m not sure what I’m doing. Different formulas lead to very different result. I want to know which one is correct. On the other hand, doing this helped me learn a bit of math and understand them a bit easier.
rgb2ryb1 : split_opacity l[0] +compose_channels[0] min to_rgb -.. . +compose_channels[0] max to_rgb +l[0] s c rm. a c compose_channels min endl -[0] . to_color[0] f[0] "VC=(G+B)>0?1:0;[R,VC?G/2:G,VC?B/2:B]" s[0] c +. [1] +[2] [1] rv[1,5] rm. a[0-2] c n[0] {im#0<0?0:im#0},{iM#0} k[0] endl a c
Reference - ryb2rgb.R | Políticamente Correcto
ryb2rgb: / 255 to_color f
"cubicInt(t,vA,vB) = (weight=t*t*(3-2*t);vA+weight*(vB-vA));
getR(iR,iY,iB) = (x0=cubicInt(iB,1,.163);x1=cubicInt(iB,1,0);x2=cubicInt(iB,1,.5);x3=cubicInt(iB,1,.2);y0=cubicInt(iY,x0,x1);y1=cubicInt(iY,x2,x3);cubicInt(iR,y0,y1));
getG(iR,iY,iB) = (x0=cubicInt(iB,1,.373);x1=cubicInt(iB,1,.66);x2=cubicInt(iB,0,0);x3=cubicInt(iB,.5,094);y0=cubicInt(iY,x0,x1);y1=cubicInt(iY,x2,x3);cubicInt(iR,y0,y1));
getB(iR,iY,iB) = (x0=cubicInt(iB,1,.6);x1=cubicInt(iB,0,.2);x2=cubicInt(iB,0,0.5);x3=cubicInt(iB,0,0);y0=cubicInt(iY,x0,x1);y1=cubicInt(iY,x2,x3);cubicInt(iR,y0,y1));
Rn=getR(R,G,B);
Gn=getG(R,G,B);
Bn=getB(R,G,B);
E=[Rn,Gn,Bn,A];E*255"
Reference - node-ryb2rgb/ryb2rgb.js at master · bahamas10/node-ryb2rgb · GitHub