@Test public final void testVal() { double[] pos = new double[2]; for (int i = 0; i < X.length; i++) { pos[0] = X[i]; pos[1] = Y[i]; assertEquals( "Bad accuracy for x=" + pos[0] + ", y=" + pos[1] + " in gaussian value.", val[i], g.val(pos, params), TOLERANCE); } }
public static final <T extends RealType<T>> void addGaussianSpotToImage( RandomAccessibleInterval<T> img, double[] params) { IterableInterval<T> iterImg = Views.iterable(img); Cursor<T> lc = iterImg.localizingCursor(); int nDims = img.numDimensions(); double[] position = new double[nDims]; double val; T var = iterImg.firstElement().createVariable(); while (lc.hasNext()) { lc.fwd(); lc.localize(position); val = gaussian.val(position, params); var.setReal(val); lc.get().add(var); } }