Skip to content

Commit 10ab745

Browse files
author
tibuch
committed
Code cleanup after rebase.
1 parent 5a0145e commit 10ab745

13 files changed

+105
-168
lines changed

src/main/java/net/imagej/ops/features/sets/AbstractComputerSet.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,9 @@ protected void addComputer(final Class<? extends Op> clazz) {
168168
* {@inheritDoc}
169169
*/
170170
@Override
171-
public Map<String, O> compute1(final I input) {
171+
public Map<String, O> calculate(I input) {
172+
computers.values().parallelStream().forEach(c -> c.compute(input, c.out()));
172173

173-
computers.values().parallelStream().forEach(c -> c.compute1(input, c.out()));
174-
175174
return namedOutputs;
176175
}
177176

src/main/java/net/imagej/ops/features/sets/AbstractConfigurableComputerSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ protected void initialize(final Collection<OpInfo> infos) {
143143
* {@inheritDoc}
144144
*/
145145
@Override
146-
public Map<String, O> compute1(final I input) {
146+
public Map<String, O> calculate(final I input) {
147147

148148
activated.entrySet().parallelStream().filter(a -> a.getValue())
149-
.map(a -> computers.get(a.getKey())).forEach(c -> c.compute1(input, c.out()));
149+
.map(a -> computers.get(a.getKey())).forEach(c -> c.compute(input, c.out()));
150150

151151
return namedOutputs;
152152
}

src/main/java/net/imagej/ops/features/sets/DefaultGeometric2DComputerSet.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@
3535
import net.imagej.ops.Ops.Geometric.Circularity;
3636
import net.imagej.ops.Ops.Geometric.Convexity;
3737
import net.imagej.ops.Ops.Geometric.Eccentricity;
38-
import net.imagej.ops.Ops.Geometric.FeretsAngle;
39-
import net.imagej.ops.Ops.Geometric.FeretsDiameter;
4038
import net.imagej.ops.Ops.Geometric.MainElongation;
4139
import net.imagej.ops.Ops.Geometric.MajorAxis;
40+
import net.imagej.ops.Ops.Geometric.MaximumFeretsAngle;
41+
import net.imagej.ops.Ops.Geometric.MaximumFeretsDiameter;
42+
import net.imagej.ops.Ops.Geometric.MinimumFeretsAngle;
43+
import net.imagej.ops.Ops.Geometric.MinimumFeretsDiameter;
4244
import net.imagej.ops.Ops.Geometric.MinorAxis;
4345
import net.imagej.ops.Ops.Geometric.Roundness;
44-
import net.imagej.ops.Ops.Geometric.Rugosity;
4546
import net.imagej.ops.Ops.Geometric.Size;
4647
import net.imagej.ops.Ops.Geometric.Solidity;
4748
import net.imagej.ops.features.sets.processors.ComputerSetProcessorUtils;
@@ -68,8 +69,9 @@ public DefaultGeometric2DComputerSet() {
6869
@Override
6970
public Class<? extends Op>[] getComputers() {
7071
return new Class[] { Boxivity.class, Convexity.class, Circularity.class, Eccentricity.class,
71-
MainElongation.class, FeretsAngle.class, FeretsDiameter.class, MajorAxis.class, MinorAxis.class,
72-
BoundarySize.class, Roundness.class, Rugosity.class, Solidity.class, Size.class };
72+
MainElongation.class, MinimumFeretsAngle.class, MaximumFeretsAngle.class, MinimumFeretsDiameter.class,
73+
MaximumFeretsDiameter.class, MajorAxis.class, MinorAxis.class, BoundarySize.class, Roundness.class,
74+
Solidity.class, Size.class };
7375
}
7476

7577
@Override

src/main/java/net/imagej/ops/features/sets/DefaultHistogramComputerSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ protected void addComputer(final Class<? extends Op> clazz) {
9191
}
9292

9393
@Override
94-
public Map<String, LongType> compute1(final Iterable input) {
95-
final Histogram1d histogram = histogramFunc.compute1(input);
94+
public Map<String, LongType> calculate(final Iterable input) {
95+
final Histogram1d histogram = histogramFunc.calculate(input);
9696
final Map<String, LongType> result = new HashMap<>();
9797
for (int i = 0; i < numBins; i++) {
9898
result.put(getKey(i), new LongType(histogram.frequency(i)));

src/main/java/net/imagej/ops/features/sets/DefaultZernikeComputerSet.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@
5555
public class DefaultZernikeComputerSet extends AbstractConfigurableComputerSet<Iterable, DoubleType>
5656
implements ZernikeComputerSet<Iterable, DoubleType> {
5757

58-
public DefaultZernikeComputerSet() {
59-
super(new DoubleType(), Iterable.class);
60-
}
61-
6258
@Parameter(type = ItemIO.INPUT, label = "Minimum Order of Zernike Moment", description = "The minimum order of the zernike moment to be calculated.", min = "1", max = "2147483647", stepSize = "1")
6359
private int orderMin = 2;
6460

6561
@Parameter(type = ItemIO.INPUT, label = "Maximum Order of Zernike Moment", description = "The maximum order of the zernike moment to be calculated.", min = "1", max = "2147483647", stepSize = "1")
6662
private int orderMax = 4;
63+
64+
public DefaultZernikeComputerSet() {
65+
super(new DoubleType(), Iterable.class);
66+
}
6767

6868
@SuppressWarnings("unchecked")
6969
@Override

src/main/java/net/imagej/ops/features/sets/processors/IterableComputerSetProcessor.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131

3232
import java.util.Arrays;
3333
import java.util.Map;
34+
import java.util.Map.Entry;
3435

3536
import net.imagej.ops.Op;
3637
import net.imagej.ops.features.sets.ComputerSet;
3738
import net.imagej.ops.features.sets.tables.ComputerSetTableService;
38-
import net.imagej.ops.features.sets.tables.DefaultTable;
3939
import net.imagej.ops.special.computer.Computers;
4040
import net.imagej.table.GenericTable;
4141
import net.imglib2.type.Type;
@@ -45,11 +45,11 @@
4545

4646
/**
4747
* An IterableProcessor holds {@link ComputerSet}s and
48-
* {@link IterableComputerSetProcessor#compute1(Iterable, GenericTable)} computes the
49-
* {@link Computers} on the given {@link Iterable} and returns a
50-
* {@link DefaultTable}.
48+
* {@link IterableComputerSetProcessor#compute(Iterable, GenericTable)} computes
49+
* the {@link Computers} on the given {@link Iterable} and returns a
50+
* {@link GenericTable}.
5151
*
52-
* The {@link DefaultTable} has one row and as many columns as {@link Computers}
52+
* The {@link GenericTable} has one row and as many columns as {@link Computers}
5353
* were calculated.
5454
*
5555
* @author Tim-Oliver Buchholz, University of Konstanz
@@ -68,31 +68,27 @@ public class IterableComputerSetProcessor<I, O extends Type<O>>
6868

6969
/**
7070
* Maps each {@link ComputerSet} to a unique name. This ensures unique
71-
* column names in the {@link DefaultTable}.
71+
* column names in the {@link GenericTable}.
7272
*/
7373
private Map<ComputerSet<?, O>, String> names;
7474

75-
@Override
76-
public void initialize() {
77-
super.initialize();
78-
}
79-
8075
@Override
8176
public GenericTable createOutput(final Iterable<I> input1) {
8277
names = ComputerSetProcessorUtils.getUniqueNames(Arrays.asList(computerSets));
8378
return csts.createTable(computerSets, names, 1);
8479
}
8580

8681
@Override
87-
public void compute1(final Iterable<I> input1, final GenericTable output) {
82+
public void compute(final Iterable<I> input1, final GenericTable output) {
8883

8984
Arrays.asList(computerSets).parallelStream().forEach(c -> {
90-
final Map<String, O> result = c.compute1(input1);
91-
for (final String name : result.keySet()) {
92-
output.set(ComputerSetProcessorUtils.getComputerTableName(names.get(c), name), 0, result.get(name));
85+
final Map<String, O> result = c.calculate(input1);
86+
for (final Entry<String, O> entry : result.entrySet()) {
87+
output.set(ComputerSetProcessorUtils.getComputerTableName(names.get(c), entry.getKey()), 0,
88+
entry.getValue());
9389
}
9490
});
95-
91+
9692
}
9793

9894
}

src/main/java/net/imagej/ops/features/sets/processors/LabelRegionsComputerSetProcessor.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131

3232
import java.util.Arrays;
3333
import java.util.Map;
34+
import java.util.Map.Entry;
3435
import java.util.concurrent.atomic.AtomicInteger;
3536
import java.util.stream.StreamSupport;
3637

3738
import net.imagej.ops.Op;
3839
import net.imagej.ops.features.sets.ComputerSet;
3940
import net.imagej.ops.features.sets.tables.ComputerSetTableService;
40-
import net.imagej.ops.features.sets.tables.DefaultTable;
4141
import net.imagej.ops.special.computer.Computers;
4242
import net.imagej.table.GenericTable;
4343
import net.imglib2.roi.labeling.LabelRegion;
@@ -49,11 +49,11 @@
4949

5050
/**
5151
* A LabelRegionsProcessor holds {@link ComputerSet}s and
52-
* {@link LabelRegionsComputerSetProcessor#compute1(LabelRegions, GenericTable)}
52+
* {@link LabelRegionsComputerSetProcessor#compute(LabelRegions, GenericTable)}
5353
* computes the {@link Computers} on the given {@link LabelRegions} and returns a
54-
* {@link DefaultTable}.
54+
* {@link GenericTable}.
5555
*
56-
* The {@link DefaultTable} holds for each {@link LabelRegion} a row and has as
56+
* The {@link GenericTable} holds for each {@link LabelRegion} a row and has as
5757
* many columns as {@link Computers} were calculated.
5858
*
5959
* @author Tim-Oliver Buchholz, University of Konstanz
@@ -74,7 +74,7 @@ public class LabelRegionsComputerSetProcessor<S, F, O extends Type<O>>
7474

7575
/**
7676
* Maps each {@link ComputerSet} to a unique name. This ensures unique
77-
* column names in the {@link DefaultTable}.
77+
* column names in the {@link GenericTable}.
7878
*/
7979
private Map<ComputerSet<?, O>, String> names;
8080

@@ -87,23 +87,22 @@ public class LabelRegionsComputerSetProcessor<S, F, O extends Type<O>>
8787
public GenericTable createOutput(final LabelRegions<S> input1) {
8888
names = ComputerSetProcessorUtils.getUniqueNames(Arrays.asList(computerSets));
8989
labelColumnName = ComputerSetProcessorUtils.uniqueName(names.values(), "Label");
90-
GenericTable table = csts.createTable(computerSets, names, labelColumnName, input1.getExistingLabels().size());
91-
return table;
90+
return csts.createTable(computerSets, names, labelColumnName, input1.getExistingLabels().size());
9291
}
9392

9493
@Override
95-
public void compute1(final LabelRegions<S> input1, final GenericTable output) {
94+
public void compute(final LabelRegions<S> input1, final GenericTable output) {
9695

9796
AtomicInteger rowIdx = new AtomicInteger(0);
9897

9998
StreamSupport.stream(input1.spliterator(), true).parallel().forEach(r -> {
10099
final int j = rowIdx.getAndIncrement();
101100
for (final ComputerSet<F, O> computerSet : computerSets) {
102101
// LabelRegion has to be converted to Polygon or Mesh.
103-
final Map<String, O> result = computerSet.compute1(cs.convert(r, computerSet.getInType()));
104-
for (final String name : result.keySet()) {
105-
output.set(ComputerSetProcessorUtils.getComputerTableName(names.get(computerSet), name), j,
106-
result.get(name));
102+
final Map<String, O> result = computerSet.calculate(cs.convert(r, computerSet.getInType()));
103+
for (final Entry<String, O> entry : result.entrySet()) {
104+
output.set(ComputerSetProcessorUtils.getComputerTableName(names.get(computerSet), entry.getKey()), j,
105+
result.get(entry.getValue()));
107106
}
108107
}
109108
output.set(labelColumnName, j, r.getLabel());

src/main/java/net/imagej/ops/features/sets/processors/ROIComputerSetProcessor.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
import java.util.Arrays;
3333
import java.util.HashSet;
3434
import java.util.Map;
35+
import java.util.Map.Entry;
3536
import java.util.Set;
3637
import java.util.concurrent.atomic.AtomicInteger;
3738

3839
import net.imagej.ops.Op;
3940
import net.imagej.ops.features.sets.ComputerSet;
4041
import net.imagej.ops.features.sets.tables.ComputerSetTableService;
41-
import net.imagej.ops.features.sets.tables.DefaultTable;
4242
import net.imagej.ops.special.computer.Computers;
4343
import net.imagej.table.GenericTable;
4444
import net.imglib2.RandomAccessible;
@@ -54,11 +54,11 @@
5454

5555
/**
5656
* A ROIProcessor holds {@link ComputerSet}s and
57-
* {@link ROIComputerSetProcessor#compute2(RandomAccessible, LabelRegions, GenericTable)}
58-
* computes the {@link Computers} on the sampled {@link LabelRegion} of I and returns a
59-
* {@link DefaultTable}.
57+
* {@link ROIComputerSetProcessor#compute(RandomAccessible, LabelRegions, GenericTable)}
58+
* computes the {@link Computers} on the sampled {@link LabelRegion} of I and
59+
* returns a {@link GenericTable}.
6060
*
61-
* The {@link DefaultTable} holds for each {@link LabelRegion} a row and has as
61+
* The {@link GenericTable} holds for each {@link LabelRegion} a row and has as
6262
* many columns as {@link Computers} were calculated.
6363
*
6464
* @author Tim-Oliver Buchholz, University of Konstanz
@@ -79,7 +79,7 @@ public class ROIComputerSetProcessor<T extends Type<T>, S, O extends Type<O>>
7979

8080
/**
8181
* Maps each {@link ComputerSet} to a unique name. This ensures unique
82-
* column names in the {@link DefaultTable}.
82+
* column names in the {@link GenericTable}.
8383
*/
8484
private Map<ComputerSet<?, O>, String> names;
8585

@@ -92,28 +92,24 @@ public class ROIComputerSetProcessor<T extends Type<T>, S, O extends Type<O>>
9292
public GenericTable createOutput(final RandomAccessible<T> input1, final LabelRegions<S> input2) {
9393
names = ComputerSetProcessorUtils.getUniqueNames(Arrays.asList(computerSets));
9494
labelColumnName = ComputerSetProcessorUtils.uniqueName(names.values(), "Label");
95-
GenericTable table = csts.createTable(computerSets, names, labelColumnName, input2.getExistingLabels().size());
96-
return table;
95+
return csts.createTable(computerSets, names, labelColumnName, input2.getExistingLabels().size());
9796
}
9897

9998
@Override
100-
public void compute2(final RandomAccessible<T> input1, final LabelRegions<S> input2,
101-
final GenericTable output) {
102-
99+
public void compute(final RandomAccessible<T> input1, final LabelRegions<S> input2, final GenericTable output) {
100+
103101
Set<Pair<Iterable<T>, S>> regions = new HashSet<>();
104-
input2.forEach(r -> {
105-
regions.add(new ValuePair<Iterable<T>, S>(Regions.sample(r, input1), r.getLabel()));
106-
});
102+
input2.forEach(r -> regions.add(new ValuePair<Iterable<T>, S>(Regions.sample(r, input1), r.getLabel())));
107103

108104
AtomicInteger rowIdx = new AtomicInteger(0);
109-
105+
110106
regions.parallelStream().forEach(p -> {
111107
final int j = rowIdx.getAndIncrement();
112108
for (final ComputerSet<Iterable<T>, O> computerSet : computerSets) {
113-
final Map<String, O> result = computerSet.compute1(p.getA());
114-
for (final String name : result.keySet()) {
115-
output.set(ComputerSetProcessorUtils.getComputerTableName(names.get(computerSet), name), j,
116-
result.get(name));
109+
final Map<String, O> result = computerSet.calculate(p.getA());
110+
for (final Entry<String, O> entry : result.entrySet()) {
111+
output.set(ComputerSetProcessorUtils.getComputerTableName(names.get(computerSet), entry.getKey()),
112+
j, entry.getValue());
117113
}
118114
}
119115
output.set(labelColumnName, j, p.getB());

src/main/java/net/imagej/ops/features/sets/tables/DefaultTable.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)