Skip to content

Commit a114884

Browse files
committed
Add optional params to BoxCount
1 parent 025dd2d commit a114884

2 files changed

Lines changed: 30 additions & 10 deletions

File tree

scijava-ops-image/src/main/java/org/scijava/ops/image/topology/BoxCount.java

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import net.imglib2.view.Views;
4848

4949
import org.scijava.function.Functions;
50+
import org.scijava.ops.spi.Nullable;
5051

5152
/**
5253
* An N-dimensional box counting that can be used to estimate the fractal
@@ -103,11 +104,15 @@ private BoxCount() {
103104
* @return A list of (log(foreground count), -log(section size))
104105
* {@link ValuePair} objects for curve fitting
105106
*/
106-
public static <B extends BooleanType<B>>
107-
List<ValuePair<DoubleType, DoubleType>> apply(
108-
final RandomAccessibleInterval<B> input, final Long maxSize,
109-
final Long minSize, final Double scaling, final Long gridMoves)
110-
{
107+
public static <B extends BooleanType<B>> //
108+
List<ValuePair<DoubleType, DoubleType>> apply( //
109+
final RandomAccessibleInterval<B> input, //
110+
final Long maxSize, //
111+
final Long minSize, //
112+
final Double scaling, //
113+
final Long gridMoves //
114+
) {
115+
111116
if (scaling <= 1.0) {
112117
throw new IllegalArgumentException(
113118
"Scaling must be > 1.0 or algorithm won't stop.");
@@ -344,10 +349,25 @@ class DefaultBoxCount<B extends BooleanType<B>> implements
344349
* @return the output
345350
*/
346351
@Override
347-
public List<ValuePair<DoubleType, DoubleType>> apply(
348-
RandomAccessibleInterval<B> input, Long maxSize, Long minSize,
349-
Double scaling, Long gridMoves)
350-
{
352+
public List<ValuePair<DoubleType, DoubleType>> apply( //
353+
final RandomAccessibleInterval<B> input, //
354+
@Nullable Long maxSize, //
355+
@Nullable Long minSize, //
356+
@Nullable Double scaling, //
357+
@Nullable Long gridMoves //
358+
) {
359+
if (maxSize == null) {
360+
maxSize = 48L;
361+
}
362+
if (minSize == null) {
363+
minSize = 5L;
364+
}
365+
if (scaling == null) {
366+
scaling = 1.2;
367+
}
368+
if (gridMoves == null) {
369+
gridMoves = 0L;
370+
}
351371
return BoxCount.apply(input, maxSize, minSize, scaling, gridMoves);
352372
}
353373

scijava-ops-image/src/test/java/org/scijava/ops/image/OpRegressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class OpRegressionTest {
4242

4343
@Test
4444
public void opDiscoveryRegressionIT() {
45-
long expected = 1878;
45+
long expected = 1882;
4646
long actual = ops.infos().size();
4747
assertEquals(expected, actual);
4848
}

0 commit comments

Comments
 (0)