Skip to content

Commit 6f2f14b

Browse files
wiedenmctrueden
authored andcommitted
WIP/Discuss: Make numBins parameter optional in HistogramCreate
1 parent 52418c5 commit 6f2f14b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/main/java/net/imagej/ops/image/histogram/HistogramCreate.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,15 +49,19 @@
4949
*/
5050
@Plugin(type = Op.class, name = "image.histogram")
5151
@Parameter(key = "iterable")
52-
@Parameter(key = "numBins")
52+
@Parameter(key = "numBins", required = false)
5353
@Parameter(key = "histogram", type = ItemIO.OUTPUT)
5454
public class HistogramCreate<T extends RealType<T>> implements BiFunction<Iterable<T>, Integer, Histogram1d<T>>{
5555

56+
public static final int DEFAULT_NUM_BINS = 256;
57+
5658
@OpDependency(name = "stats.minMax")
5759
private Function<Iterable<T>, Pair<T, T>> minMaxFunc;
5860

5961
@Override
60-
public Histogram1d<T> apply(final Iterable<T> input, final Integer numBins) {
62+
public Histogram1d<T> apply(final Iterable<T> input, Integer numBins) {
63+
if (numBins == null) numBins = DEFAULT_NUM_BINS;
64+
6165
final Pair<T, T> res = minMaxFunc.apply(input);
6266

6367
final Histogram1d<T> histogram1d = new Histogram1d<>(

0 commit comments

Comments
 (0)