Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix float histograms #4475

Merged
merged 2 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-
Expand Down
16 changes: 0 additions & 16 deletions util/src/main/scala/com/scalableminds/util/tools/Math.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down