diff --git a/src/Histogram.ts b/src/Histogram.ts index ae57ef26..0ec845e9 100644 --- a/src/Histogram.ts +++ b/src/Histogram.ts @@ -46,16 +46,15 @@ export default class Histogram { this.max = hinfo.max; this.binSize = hinfo.binSize; - // track the first and last nonzero bins with at least 1 sample - // TODO: If `this.min` is not 0, should `this.dataMinBin` be `0` (instead of starting at 1) - // since the first bin doesn't represent zero values? - for (let i = 1; i < this.bins.length; i++) { + // TODO: These should always return 0 and NBINS - 1, respectively. Test if these + // can be removed. + for (let i = 0; i < this.bins.length; i++) { if (this.bins[i] > 0) { this.dataMinBin = i; break; } } - for (let i = this.bins.length - 1; i >= 1; i--) { + for (let i = this.bins.length - 1; i >= 0; i--) { if (this.bins[i] > 0) { this.dataMaxBin = i; break; diff --git a/src/test/lut.test.ts b/src/test/lut.test.ts index 62cfdae3..e0e0a92c 100644 --- a/src/test/lut.test.ts +++ b/src/test/lut.test.ts @@ -14,9 +14,8 @@ describe("test histogram", () => { const histogram = new Histogram(conedata); describe("binary volume data", () => { - it("has a min of 255", () => { - // histogram dataMin is the min nonzero value - expect(histogram.getMin()).to.equal(255); + it("has a min of 0", () => { + expect(histogram.getMin()).to.equal(0); }); it("has a max of 255", () => { expect(histogram.getMax()).to.equal(255);