@Override public O compute(I x, O output) { output.setZero(); return output; }
@Override public void setZero() { t.setZero(); }
@Override public O compute(I x, O output) { output.setZero(); return output; }
@Override public void setZero() { t.setZero(); }
public BinaryMaskToCost( final R maxValForR ) { this.maxValForR = maxValForR; this.zero = maxValForR.createVariable(); zero.setZero(); }
@Override public O compute(I x, O output) { if (x.getRealDouble() < 0) output.setZero(); else output.setOne(); return output; }
@Override public void compute(final I input, final O output) { if (input.getRealDouble() < 0) output.setZero(); else output.setOne(); } }
@Override public O compute(I x, O output) { if (x.getRealDouble() < 0) output.setZero(); else output.setOne(); return output; }
public Comparison( final O scrap, final OFunction< O > a, final OFunction< O > b) { this.a = a; this.b = b; this.zero = scrap.createVariable(); this.zero.setZero(); this.one = scrap.createVariable(); this.one.setOne(); }
@Override public void compute(final Histogram<T> histogram, final T output) { sum.setZero(); for (int i=0; i<histogram.bins.length; ++i) { op.setReal(histogram.bins[i] * histogram.binValue(i).getRealDouble()); sum.add(op); } output.setReal(sum.getRealDouble() / histogram.nPixels); } }
@Override public void evaluate(NewIterableInterval<U> i, V output) { if (crs == null) crs = i.cursor(); crs.reset(); double sum = 0; long numElements = 0; while (crs.hasNext()) { sum += crs.next().getRealDouble(); numElements++; } if (numElements == 0) output.setZero(); else output.setReal(sum / numElements); }
@Override public void compute(final Histogram<T> histogram, final T median, final T output) { sum.setZero(); for (int i = histogram.nBins() -1; i> -1; --i) { e.setReal(histogram.binValue(i).getRealDouble() - median.getRealDouble()); ecopy.set(e); e.mul(ecopy); // pow(x, 2) e.mul(histogram.bins[i]); sum.add(e); } output.setReal(Math.sqrt(sum.getRealDouble() / histogram.nPixels)); } }
public void evaluate(Cursor<U> cursor, V output) { // need to make a copy of the cursor as we will change its position and // parent might hate that. (MAYBE I'M WRONG HERE). But any function that // evals another function needs its own cursor if (crs == null) { crs = cursor.copyCursor(); //position = new long[cursor.numDimensions()]; } //cursor.localize(position); // EXPENSIVE as setPosition() call from pure method //cursor.relocate(position); // NOPE - can't do this type of needed op crs.reset(); double sum = 0; long numElements = 0; while (crs.hasNext()) { sum += crs.next().getRealDouble(); numElements++; } if (numElements == 0) output.setZero(); else output.setReal(sum / numElements); }
/** * Add 0s before axis minimum. * * @param input Input RAI * @return An extended and cropped version of input */ private <T extends RealType<T>> RandomAccessibleInterval<T> addLeadingZeros( RandomAccessibleInterval<T> input) { final long[] min = Intervals.minAsLongArray(input); final long[] max = Intervals.maxAsLongArray(input); for (int i = 0; i < max.length; i++) { min[i]--; } final T realZero = Util.getTypeFromInterval(input).copy(); realZero.setZero(); final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extendedImg = Views.extendValue(input, realZero); final IntervalView<T> offsetInterval = Views.interval(extendedImg, min, max); return Views.zeroMin(offsetInterval); }
zeroType.setZero();
zeroType.setZero();