jit.convolve within Java?

Sep 15, 2010 at 4:36am

jit.convolve within Java?

Is it possible to make use of jit.convolve within a Java context? I believe that it should be possible to set the convolution kernel as in the example below, but when I retrieve the “in2_name” attribute it comes back as null, even after explicitly setting it.


import com.cycling74.jitter.JitterMatrix;
import com.cycling74.jitter.JitterObject;
import com.cycling74.max.Atom;
import com.cycling74.max.MaxObject;

public class Test extends MaxObject
{
private JitterObject conv;
private JitterMatrix kernel;

public Test( int width, int height )
{
// declare convolution kernel
kernel = new JitterMatrix( 1, "float32", 3, 3 );
kernel.setcell2d( 1, 0, new float[] { 1.f } );
post( "my kernel: " + kernel.getName() );

// create jit.convolve and set kernel
conv = new JitterObject( "jit.convolve" );

post( "BEFORE default kernel: " + conv.getAttr( "in2_name" ) );
conv.setAttr( "in2_name", kernel.getName() );
post( "AFTER explicit kernel: " + conv.getAttr( "in2_name" ) );
}

public void notifyDeleted()
{
conv.freePeer();
kernel.freePeer();
}
}

#52307
Sep 15, 2010 at 6:55am

There’s no in2_name in a Jitter object as used from Java (or JS or C). You want to pass in an array of matrices to the matrixcalc method. Sorry there’s not a clearer example of this in Java, but it’s similar to Javascript.

For example, when processing a matrix, something like:

conv.matrixcalc(new JitterMatrix[] {input, kernel}, output);

#187987
Sep 15, 2010 at 9:09am

Thanks Joshua – got it now.

#187988

You must be logged in to reply to this topic.