|
6 | 6 | * %% |
7 | 7 | * Redistribution and use in source and binary forms, with or without |
8 | 8 | * modification, are permitted provided that the following conditions are met: |
9 | | - * |
| 9 | + * |
10 | 10 | * 1. Redistributions of source code must retain the above copyright notice, |
11 | 11 | * this list of conditions and the following disclaimer. |
12 | 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
13 | 13 | * this list of conditions and the following disclaimer in the documentation |
14 | 14 | * and/or other materials provided with the distribution. |
15 | | - * |
| 15 | + * |
16 | 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
17 | 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
18 | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
49 | 49 | */ |
50 | 50 | @Plugin(type = Op.class, name = "image.histogram") |
51 | 51 | @Parameter(key = "iterable") |
52 | | -@Parameter(key = "numBins") |
| 52 | +@Parameter(key = "numBins", required = false) |
53 | 53 | @Parameter(key = "histogram", type = ItemIO.OUTPUT) |
54 | 54 | public class HistogramCreate<T extends RealType<T>> implements BiFunction<Iterable<T>, Integer, Histogram1d<T>>{ |
55 | 55 |
|
| 56 | + public static final int DEFAULT_NUM_BINS = 256; |
| 57 | + |
56 | 58 | @OpDependency(name = "stats.minMax") |
57 | 59 | private Function<Iterable<T>, Pair<T, T>> minMaxFunc; |
58 | 60 |
|
59 | 61 | @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 | + |
61 | 65 | final Pair<T, T> res = minMaxFunc.apply(input); |
62 | 66 |
|
63 | 67 | final Histogram1d<T> histogram1d = new Histogram1d<>( |
|
0 commit comments