Jump to content

COP2 VEX Filter using ninput does not work


jonklein

Recommended Posts

Hello houdini-community!

I'm trying to create an outline filter using vex. You can find the code below, I copied it from the SideFX-Forum. I put the code in a vfl file and compiled it to a hda-file using vcc. Then, I imported the HDA into a simple project, got a Render compositing node and wired its output into my custom outline-node. As a result I just get a completely black image. I've looked into the components of the matrix3 that ninput returns and they are always just 0, although my render-output has almost no black pixels.

Is there anyone who has an idea what I might be missing? Any help is highly appreciated!

Edit: I fogot to mention that I tried to get the same result using a Convolve Compositing Node with the same kernel as used in the code. That works. However, this is just an experiment for me I really want to know how to implement such a filter using VEX.
 

cop2 outlines(float effect = 1)
{
matrix3 kernel;
matrix3 pixels;
vector4 col;
float result;
int i, x, y;

col = 0.0;

// this builds a kernel with -1/8 in all elements but the center, which is
// +1 (an edge detect kernel, sums to 0); for sharpen, use effect+1
// for the center pixel
kernel = 0;
for(x=0; x<3; x++)
for(y=0; y<3; y++)
setcomp(kernel, -effect/8, x,y);
setcomp(kernel, effect, 1,1);

// iterate over all components in the current plane (PL)
for(i=0; i<4; i++)
{
pixels = ninput(0, PL, 0, i, IX, IY, FR);

// sum the results of the kernel x pixels
result = 0;
for(x=0; x<3; x++)
for(y=0; y<3; y++)
result += getcomp(pixels,x,y) * getcomp(kernel,x,y);

setcomp(col, result, i);
}

assign(Cr, Cg, Cb, C4, col);
}

 

Edited by jonklein
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...