@Override public OUT compute(IN input, OUT out) { if (!input.iterationOrder().equals(out.iterationOrder())) { throw new IllegalArgumentException( "IterationOrders not the same in StandardMultilevelThresholder"); } Cursor<T> outputCursor = out.cursor(); Cursor<T> inputCursor = input.cursor(); ThresholdValueCollection thresholdValues = m_op.compute(input); double[] sortedValues = thresholdValues.getSortedVector(); while (inputCursor.hasNext()) { outputCursor.fwd(); double value = inputCursor.next().getRealDouble(); int idx = 0; for (int d = 0; d < sortedValues.length; d++) { if (value > sortedValues[d]) { idx++; } else { break; } } outputCursor.get().setReal(idx); } return out; }
@Override public UnaryOperation<IN, OUT> copy() { return new MultilevelThresholderOp<T, IN, OUT>(m_op.copy()); }