Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Holcomb <bob_holcomb@hotmail.com>2010-08-16 02:08:49 +0400
committerRobert Holcomb <bob_holcomb@hotmail.com>2010-08-16 02:08:49 +0400
commite9683f4b265a7aebb2388ff32779af0aaca50ec4 (patch)
tree38353949307ef680a269f509fde4ca0e47fb30f1
parent247a406027e9db21316c6bfcd615ac39ad76466a (diff)
Fixed bug in normalition of YCbCr color space conversion (from 0..1 to
-1..1) to fix errors in keying. Simplified chroma key to not take despill into consideration (handled elsewhere). Simplified user interface for pieces not used.
-rw-r--r--source/blender/editors/space_node/drawnode.c4
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c86
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c2
3 files changed, 52 insertions, 40 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index a74b070e6cd..f04cefc6d2b 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -823,9 +823,9 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *C, Point
uiItemR(col, ptr, "cutoff", 0, NULL, 0);
col= uiLayoutColumn(layout, 1);
- uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, 0);
+ /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, 0); Removed for now */
uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, 0);
- uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, 0);
+ /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, 0); Removed for now*/
}
static void node_composit_buts_color_matte(uiLayout *layout, bContext *C, PointerRNA *ptr)
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c
index b081880b87b..b14109d1b52 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c
@@ -44,20 +44,38 @@ static bNodeSocketType cmp_node_chroma_out[]={
static void do_rgba_to_ycca_normalized(bNode *node, float *out, float *in)
{
- /*normalize to the range -1.0 to 1.0) */
- rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601);
- out[0]=((out[0])-16)/255.0;
- out[1]=((out[1])-128)/255.0;
- out[2]=((out[2])-128)/255.0;
+ rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601);
+
+ //normalize to 0..1.0
+ out[0]=out[0]/255.0;
+ out[1]=out[1]/255.0;
+ out[2]=out[2]/255.0;
+
+ //rescale to -1.0..1.0
+ out[0]=(out[0]*2.0)-1.0;
+ out[1]=(out[1]*2.0)-1.0;
+ out[2]=(out[2]*2.0)-1.0;
+
+// out[0]=((out[0])-16)/255.0;
+// out[1]=((out[1])-128)/255.0;
+// out[2]=((out[2])-128)/255.0;
out[3]=in[3];
}
static void do_ycca_to_rgba_normalized(bNode *node, float *out, float *in)
{
- /*un-normalize the normalize from above */
- in[0]=(in[0]*255.0)+16;
- in[1]=(in[1]*255.0)+128;
- in[2]=(in[2]*255.0)+128;
+ /*un-normalize the normalize from above */
+ in[0]=(in[0]+1.0)/2.0;
+ in[1]=(in[1]+1.0)/2.0;
+ in[2]=(in[2]+1.0)/2.0;
+
+ in[0]=(in[0]*255.0);
+ in[1]=(in[1]*255.0);
+ in[2]=(in[2]*255.0);
+
+// in[0]=(in[0]*255.0)+16;
+// in[1]=(in[1]*255.0)+128;
+// in[2]=(in[2]*255.0)+128;
ycc_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601);
out[3]=in[3];
}
@@ -65,47 +83,41 @@ static void do_ycca_to_rgba_normalized(bNode *node, float *out, float *in)
static void do_chroma_key(bNode *node, float *out, float *in)
{
NodeChroma *c;
- float x, z, alpha;
- float theta, beta, angle;
- float kfg, newY, newCb, newCr;
+ float x, z, kx, kz, alpha;
+ float theta, beta, angle, angle2;
+ float kfg, newY, newCb, newCr;
c=node->storage;
- /* Algorithm from book "Video Demistified" */
+ /* Algorithm from book "Video Demistified," does not include the spill reduction part */
/* find theta, the angle that the color space should be rotated based on key*/
- theta=atan2(c->key[2],c->key[1]);
+ theta=atan2(c->key[2], c->key[1]);
/*rotate the cb and cr into x/z space */
- x=in[1]*cos(theta)+in[2]*sin(theta);
- z=in[2]*cos(theta)-in[1]*sin(theta);
+ x=in[1]*cos(theta)+in[2]*sin(theta);
+ z=in[2]*cos(theta)-in[1]*sin(theta);
- /*if within the acceptance angle */
- angle=c->t1*M_PI/180.0; /* convert to radians */
+ /*if within the acceptance angle */
+ angle=c->t1*M_PI/180.0; /* convert to radians */
- /* if kfg is <0 then the pixel is outside of the key color */
- kfg=x-(fabs(z)/tan(angle/2.0));
+ /* if kfg is <0 then the pixel is outside of the key color */
+ kfg=x-(fabs(z)/tan(angle/2.0));
- if(kfg>0.0) { /* found a pixel that is within key color */
+ out[0]=in[0];
+ out[1]=in[1];
+ out[2]=in[2];
- newY=in[0]-(1-c->t3)*kfg;
- newCb=in[1]-kfg*cos((double)theta);
- newCr=in[2]-kfg*sin((double)theta);
- alpha=(kfg+c->fsize)*(c->fstrength);
+ if(kfg>0.0) { /* found a pixel that is within key color */
+ alpha=(1.0-kfg)*(c->fstrength);
- beta=atan2(newCr,newCb);
- beta=beta*180.0/M_PI; /* convert to degrees for compare*/
-
- /* if beta is within the clippin angle */
- if(fabs(beta)<(c->t2/2.0)) {
- newCb=0.0;
- newCr=0.0;
- alpha=0.0;
- }
+ beta=atan2(z,x);
+ angle2=c->t2*M_PI/180.0;
- out[0]=newY;
- out[1]=newCb;
- out[2]=newCr;
+ /* if beta is within the cutoff angle */
+ if(fabs(beta)<(angle2/2.0)) {
+ alpha=0.0;
+ }
/* don't make something that was more transparent less transparent */
if (alpha<in[3]) {
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c b/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c
index d80dd9b0a4b..0ac47c58ab3 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c
@@ -64,7 +64,7 @@ static void node_composit_exec_sephsva(void *data, bNode *node, bNodeStack **in,
if(in[0]->data==NULL) {
float h, s, v;
- rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &h, &s, &v);
+ rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &h, &s, &v);
out[0]->vec[0] = h;
out[1]->vec[0] = s;