|
| 1 | +/* |
| 2 | + * #%L |
| 3 | + * ImageJ software for multidimensional image processing and analysis. |
| 4 | + * %% |
| 5 | + * Copyright (C) 2014 - 2016 Board of Regents of the University of |
| 6 | + * Wisconsin-Madison, University of Konstanz and Brian Northan. |
| 7 | + * %% |
| 8 | + * Redistribution and use in source and binary forms, with or without |
| 9 | + * modification, are permitted provided that the following conditions are met: |
| 10 | + * |
| 11 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 12 | + * this list of conditions and the following disclaimer. |
| 13 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 14 | + * this list of conditions and the following disclaimer in the documentation |
| 15 | + * and/or other materials provided with the distribution. |
| 16 | + * |
| 17 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 21 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 24 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 25 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 27 | + * POSSIBILITY OF SUCH DAMAGE. |
| 28 | + * #L% |
| 29 | + */ |
| 30 | +package net.imagej.ops.features.sets.processors; |
| 31 | + |
| 32 | +import java.util.ArrayList; |
| 33 | +import java.util.Arrays; |
| 34 | +import java.util.List; |
| 35 | + |
| 36 | +import net.imagej.ops.Ops.Stats.Max; |
| 37 | +import net.imagej.ops.Ops.Stats.Mean; |
| 38 | +import net.imagej.ops.features.sets.ComputerSet; |
| 39 | +import net.imagej.ops.features.sets.FirstOrderStatsComputerSet; |
| 40 | +import net.imagej.ops.features.sets.tables.DefaultComputerSetTableService; |
| 41 | +import net.imagej.table.GenericTable; |
| 42 | +import net.imglib2.type.numeric.real.DoubleType; |
| 43 | +import net.imglib2.type.numeric.real.FloatType; |
| 44 | + |
| 45 | +import org.junit.Test; |
| 46 | + |
| 47 | +/** |
| 48 | + * Test for the {@link IterableComputerSetProcessor}. |
| 49 | + * |
| 50 | + * @author Tim-Oliver Buchholz, University of Konstanz |
| 51 | + * |
| 52 | + */ |
| 53 | +public class IterableComputerSetProcessorTest extends AbstractComputerSetProcessorTest { |
| 54 | + |
| 55 | + @SuppressWarnings({ "rawtypes", "unchecked" }) |
| 56 | + @Test |
| 57 | + public void allComputersAreActiveTest() { |
| 58 | + FirstOrderStatsComputerSet<Iterable, DoubleType> stats = ops.op(FirstOrderStatsComputerSet.class, |
| 59 | + Iterable.class); |
| 60 | + |
| 61 | + IterableComputerSetProcessor<FloatType, DoubleType> processor = ops.op(IterableComputerSetProcessor.class, |
| 62 | + Iterable.class, new ComputerSet[] { stats }, new DefaultComputerSetTableService<>()); |
| 63 | + |
| 64 | + GenericTable result = processor.calculate(getTestImage2D()); |
| 65 | + |
| 66 | + List<ComputerSet<?, DoubleType>> computerSets = new ArrayList<>(); |
| 67 | + computerSets.add(stats); |
| 68 | + checkAllResultTableForOneComputerSet(result, computerSets, 0); |
| 69 | + } |
| 70 | + |
| 71 | + @SuppressWarnings({ "rawtypes", "unchecked" }) |
| 72 | + @Test |
| 73 | + public void someComputersAreActiveTest() { |
| 74 | + FirstOrderStatsComputerSet<Iterable, DoubleType> stats = ops.op(FirstOrderStatsComputerSet.class, |
| 75 | + Iterable.class, Arrays.asList(new Class[] { Mean.class, Max.class })); |
| 76 | + |
| 77 | + IterableComputerSetProcessor<FloatType, DoubleType> processor = ops.op(IterableComputerSetProcessor.class, |
| 78 | + Iterable.class, new ComputerSet[] { stats }, new DefaultComputerSetTableService<>()); |
| 79 | + |
| 80 | + GenericTable result = processor.calculate(getTestImage2D()); |
| 81 | + |
| 82 | + List<ComputerSet<?, DoubleType>> computerSets = new ArrayList<>(); |
| 83 | + computerSets.add(stats); |
| 84 | + checkAllResultTableForOneComputerSet(result, computerSets, 0); |
| 85 | + } |
| 86 | + |
| 87 | + @SuppressWarnings({ "rawtypes", "unchecked" }) |
| 88 | + @Test |
| 89 | + public void multiComputerSetProcessingTest() { |
| 90 | + FirstOrderStatsComputerSet<Iterable, DoubleType> stats = ops.op(FirstOrderStatsComputerSet.class, |
| 91 | + Iterable.class); |
| 92 | + FirstOrderStatsComputerSet<Iterable, DoubleType> stats1 = ops.op(FirstOrderStatsComputerSet.class, |
| 93 | + Iterable.class, Arrays.asList(new Class[] { Mean.class, Max.class })); |
| 94 | + |
| 95 | + IterableComputerSetProcessor<FloatType, DoubleType> processor = ops.op(IterableComputerSetProcessor.class, |
| 96 | + Iterable.class, new ComputerSet[] { stats, stats1 }, new DefaultComputerSetTableService<>()); |
| 97 | + |
| 98 | + final GenericTable result = processor.calculate(getTestImage2D()); |
| 99 | + |
| 100 | + final List<ComputerSet<?, DoubleType>> computerSets = new ArrayList<>(); |
| 101 | + computerSets.add(stats); |
| 102 | + computerSets.add(stats1); |
| 103 | + checkResultTableForManyComputerSets(result, computerSets, 0); |
| 104 | + } |
| 105 | + |
| 106 | +} |
0 commit comments