Last active
March 15, 2021 02:46
-
-
Save hanslovsky/0a7513ceaed117e7bb05b4a789082de2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.imglib2.imklib.* | |
import net.imglib2.type.volatiles.* | |
import net.imglib2.type.numeric.integer.* | |
// pick any data here | |
val rawData = imklib.io.n5.openUntypedHDF5("/home/zottel/Downloads/sample_A_20160501.hdf", "volumes/raw").asUnsignedBytes() | |
val rawDataExtended = rawData.extendBorder().asInts() | |
val gradientMagnitudeData = (0..2) | |
.map { d -> LongArray(3) { if (it == d) 1 else 0 } } | |
.map { rawDataExtended[rawData + it].zeroMin - rawDataExtended[rawData - it].zeroMin } | |
.map { it * it } | |
.reduce { d1, d2 -> d1 + d2 } | |
.cache() | |
val res = doubleArrayOf(4.0, 4.0, 40.0) | |
val off = DoubleArray(3) { 0.0 } | |
val raw = paintera.baseView.addSingleScaleRawSource<UnsignedByteType, VolatileUnsignedByteType>( | |
rawData, res, off, 0.0, 255.0, "raw" | |
) | |
val gradientMagnitude = paintera.baseView.addSingleScaleRawSource<IntType, VolatileIntType>( | |
gradientMagnitudeData, res, off, 0.0, 2047.0, "gradient magnitude squared" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment