diff --git a/CHANGELOG.md b/CHANGELOG.md index 8135c44c83..f5c650a4b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md). - Fixed that converting a volume tracing into a hybrid tracing opens the hybrid tracing in "volume" mode. [#4467](https://github.com/scalableminds/webknossos/pull/4467) - Fixed a bug where users were wrongly allowed to edit the description of an annotation they were allowed to see but not update [#4466](https://github.com/scalableminds/webknossos/pull/4466) - Fixed the creation of histograms for float datasets that only have one value besides 0. [#4468](https://github.com/scalableminds/webknossos/pull/4468) +- Fixed the creation of histograms for float datasets that have values close to the minimum. [#4475](https://github.com/scalableminds/webknossos/pull/4475) ### Removed - diff --git a/util/src/main/scala/com/scalableminds/util/tools/Math.scala b/util/src/main/scala/com/scalableminds/util/tools/Math.scala index 7c62b08724..79ada5475c 100644 --- a/util/src/main/scala/com/scalableminds/util/tools/Math.scala +++ b/util/src/main/scala/com/scalableminds/util/tools/Math.scala @@ -15,22 +15,6 @@ object Math { def log2(x: Double): Double = scala.math.log(x) / lnOf2 - def roundUp(x: Double) = { - val c = x.ceil.toInt - if (c != x) - c + 1 - else - c - } - - def roundDown(x: Double) = { - val c = x.floor.toInt - if (c != x) - c - 1 - else - c - } - def clamp[T](x: T, lower: T, upper: T)(implicit num: Numeric[T]): T = { import num._ lower.max(x).min(upper) diff --git a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/FindDataService.scala b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/FindDataService.scala index f26fe21de6..c72bec644d 100644 --- a/webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/FindDataService.scala +++ b/webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/FindDataService.scala @@ -264,7 +264,7 @@ class FindDataService @Inject()(dataServicesHolder: BinaryDataServiceHolder)(imp } val bucketSize = (max - min) / 255 val finalBucketSize = if (bucketSize == 0f) 1f else bucketSize - floatData.foreach(el => counts(Math.roundDown((el - min) / finalBucketSize)) += 1) + floatData.foreach(el => counts(((el - min) / finalBucketSize).floor.toInt) += 1) extrema = (min, max) } }