/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2014 - 2015 Board of Regents of the University of
 * Wisconsin-Madison, University of Konstanz and Brian Northan.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * #L%
 */

package net.imagej.ops.threshold.apply;

import net.imagej.ops.AbstractComputerOp;
import net.imagej.ops.Ops;
import net.imglib2.type.logic.BitType;
import net.imglib2.type.numeric.RealType;

import org.scijava.Priority;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

/**
 * Applies the given threshold value to every element along the given
 * {@link Iterable} input.
 * 
 * @author Martin Horn (University of Konstanz)
 * @author Christian Dietz (University of Konstanz)
 */
@Plugin(type = Ops.Threshold.Apply.class, name = Ops.Threshold.Apply.NAME,
	priority = Priority.HIGH_PRIORITY)
public class ApplyConstantThreshold<T extends RealType<T>> extends
	AbstractComputerOp<Iterable<T>, Iterable<BitType>> implements
	Ops.Threshold.Apply
{

	@Parameter
	private T threshold;

	@Override
	public void compute(final Iterable<T> input, final Iterable<BitType> output) {
		final Object applyThreshold =
			ops().op(ApplyThresholdComparable.class, BitType.class, threshold
				.getClass(), threshold);

		// TODO: Use ops.map(...) once multithreading of BitTypes is fixed.
		ops().map(output, input, applyThreshold);
	}

}

@@ -368,17 +368,16 @@
  met:%0A *
- 
 %0A * 1. R
@@ -725,25 +725,24 @@
 ribution.%0A *
- 
 %0A * THIS SOF
@@ -1573,16 +1573,117 @@
 apply;%0A%0A
+import org.scijava.Priority;%0Aimport org.scijava.plugin.Parameter;%0Aimport org.scijava.plugin.Plugin;%0A%0A
 import n
@@ -1716,16 +1716,50 @@
 uterOp;%0A
+import net.imagej.ops.ComputerOp;%0A
 import n
@@ -1863,109 +1863,8 @@
 e;%0A%0A
-import org.scijava.Priority;%0Aimport org.scijava.plugin.Parameter;%0Aimport org.scijava.plugin.Plugin;%0A%0A
 /**%0A
@@ -1962,17 +1962,16 @@
 nput.%0A *
- 
 %0A * @aut
@@ -2370,144 +2370,191 @@
 ld;%0A
-%0A%09@Override%0A%09public void compute(final Iterable%3CT%3E input, final Iterable%3CBitType%3E output) %7B%0A%09%09final Object applyThreshold =%0A%09%09%09ops().op(
+%09private ComputerOp%3CT, BitType%3E applyThreshold;%0A%0A%09@SuppressWarnings(%22unchecked%22)%0A%09@Override%0A%09public void initialize() %7B%0A%09%09applyThreshold = (ComputerOp%3CT, BitType%3E) ops().computer(%0A%09%09%09
 Appl
@@ -2609,13 +2609,8 @@
 hold
-%0A%09%09%09%09
 .get
@@ -2617,17 +2617,20 @@
 Class(),
- 
+%0A%09%09%09
 threshol
@@ -2633,16 +2633,110 @@
 shold);%0A
+%09%7D%0A%0A%09@Override%0A%09public void compute(final Iterable%3CT%3E input, final Iterable%3CBitType%3E output) %7B
 %0A%09%09// TO

Refactor compute(in, out) method