本文整理汇总了Java中net.imglib2.type.logic.BitType类的典型用法代码示例。如果您正苦于以下问题:Java BitType类的具体用法?Java BitType怎么用?Java BitType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BitType类属于net.imglib2.type.logic包,在下文中一共展示了BitType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Override
public void run() {
statusService.showStatus("Connectivity: initialising");
final ImgPlus<BitType> bitImgPlus = Common.toBitTypeImgPlus(opService,
inputImage);
final String name = inputImage.getName();
final List<Subspace<BitType>> subspaces = HyperstackUtils.split3DSubspaces(
bitImgPlus).collect(Collectors.toList());
determineResultUnit();
matchOps(subspaces.get(0).interval);
subspaces.forEach(subspace -> {
final String suffix = subspace.toString();
final String label = suffix.isEmpty() ? name : name + " " + suffix;
subspaceConnectivity(label, subspace.interval);
});
if (SharedTable.hasData()) {
resultsTable = SharedTable.getTable();
}
}
示例2: subspaceConnectivity
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
/** Process connectivity for one 3D subspace */
private void subspaceConnectivity(final String label,
final RandomAccessibleInterval<BitType> subspace)
{
statusService.showStatus("Connectivity: calculating connectivity");
final double eulerCharacteristic = eulerCharacteristicOp.calculate(subspace)
.get();
statusService.showStatus("Connectivity: calculating euler correction");
final double edgeCorrection = eulerCorrectionOp.calculate(subspace).get();
final double correctedEuler = eulerCharacteristic - edgeCorrection;
final double connectivity = 1 - correctedEuler;
final double connectivityDensity = calculateConnectivityDensity(subspace,
connectivity);
addResults(label, eulerCharacteristic, correctedEuler, connectivity,
connectivityDensity);
}
示例3: addSubspaceTable
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
private void addSubspaceTable(final Subspace<BitType> subspace,
final List<ValuePair<DoubleType, DoubleType>> pairs)
{
final String label = inputImage.getName() + " " + subspace.toString();
final GenericColumn labelColumn = ResultUtils.createLabelColumn(label, pairs
.size());
final DoubleColumn xColumn = new DoubleColumn("-log(size)");
final DoubleColumn yColumn = new DoubleColumn("log(count)");
pairs.stream().map(p -> p.a.get()).forEach(xColumn::add);
pairs.stream().map(p -> p.b.get()).forEach(yColumn::add);
final GenericTable resultsTable = new DefaultGenericTable();
resultsTable.add(labelColumn);
resultsTable.add(xColumn);
resultsTable.add(yColumn);
subspaceTables.add(resultsTable);
}
示例4: run
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Override
public void run() {
statusService.showStatus("Surface area: initialising");
final ImgPlus<BitType> bitImgPlus = Common.toBitTypeImgPlus(ops,
inputImage);
final List<Subspace<BitType>> subspaces = HyperstackUtils.split3DSubspaces(
bitImgPlus).collect(Collectors.toList());
matchOps(subspaces.get(0).interval);
prepareResults();
statusService.showStatus("Surface area: creating meshes");
final Map<String, Mesh> meshes = processViews(subspaces);
if (exportSTL) {
getFileName();
statusService.showStatus("Surface area: saving files");
saveMeshes(meshes);
}
if (SharedTable.hasData()) {
resultsTable = SharedTable.getTable();
}
}
示例5: run
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Override
public void run() {
statusService.showStatus("Surface fraction: initializing");
final ImgPlus<BitType> bitImgPlus = Common.toBitTypeImgPlus(opService,
inputImage);
final List<Subspace<BitType>> subspaces = HyperstackUtils.split3DSubspaces(
bitImgPlus).collect(Collectors.toList());
matchOps(subspaces.get(0).interval);
prepareResultDisplay();
final String name = inputImage.getName();
subspaces.forEach(subspace -> {
final double[] results = subSpaceFraction(subspace.interval);
final String suffix = subspace.toString();
final String label = suffix.isEmpty() ? name : name + " " + suffix;
addResults(label, results);
});
if (SharedTable.hasData()) {
resultsTable = SharedTable.getTable();
}
}
示例6: subSpaceFraction
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
/** Process surface fraction for one 3D subspace in the n-dimensional image */
@SuppressWarnings("unchecked")
private double[] subSpaceFraction(
RandomAccessibleInterval<BitType> subSpace)
{
statusService.showStatus("Surface fraction: creating surface");
// Create masks for marching cubes
final RandomAccessibleInterval totalMask = raiCopy.calculate(subSpace);
// Because we want to create a surface from the whole image, set everything
// in the mask to foreground
((Img<BitType>) totalMask).forEach(BitType::setOne);
// Create surface meshes and calculate their volume. If the input interval
// wasn't binary, we'd have to threshold it before these calls.
final Mesh thresholdMesh = marchingCubes.calculate(subSpace);
statusService.showStatus("Surface fraction: calculating volume");
final double rawThresholdVolume = meshVolume.calculate(thresholdMesh).get();
final Mesh totalMesh = marchingCubes.calculate(totalMask);
final double rawTotalVolume = meshVolume.calculate(totalMesh).get();
final double thresholdVolume = rawThresholdVolume * elementSize;
final double totalVolume = rawTotalVolume * elementSize;
final double ratio = thresholdVolume / totalVolume;
return new double[] { thresholdVolume, totalVolume, ratio };
}
示例7: runRotationsInParallel
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
private List<Vector3d> runRotationsInParallel(
final RandomAccessibleInterval<BitType> interval) throws ExecutionException,
InterruptedException
{
final ExecutorService executor = Executors.newFixedThreadPool(5);
final Callable<List<Vector3d>> milTask = () -> milOp.calculate(interval);
final List<Future<List<Vector3d>>> futures = Stream.generate(() -> milTask)
.limit(rotations).map(executor::submit).collect(toList());
final List<Vector3d> pointCloud = Collections.synchronizedList(
new ArrayList<>(rotations * 3));
final int futuresSize = futures.size();
for (int j = 0; j < futuresSize; j++) {
statusService.showProgress(j, futuresSize);
final List<Vector3d> points = futures.get(j).get();
pointCloud.addAll(points);
}
executor.shutdown();
return pointCloud;
}
示例8: run
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Override
public void run() {
statusService.showStatus("Element fraction: initializing");
final ImgPlus<BitType> bitImgPlus = Common.toBitTypeImgPlus(opService,
inputImage);
prepareResultDisplay();
// The value of each foreground element in a bit type image is 1, so we can
// count their number just by summing
statusService.showStatus("Element fraction: calculating");
final double foregroundSize = opService.stats().sum(bitImgPlus)
.getRealDouble() * elementSize;
final double totalSize = bitImgPlus.size() * elementSize;
final double ratio = foregroundSize / totalSize;
addResults(foregroundSize, totalSize, ratio);
if (SharedTable.hasData()) {
resultsTable = SharedTable.getTable();
}
}
示例9: testIsAxesMatchingSpatialCalibrationDifferentScales
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Test
public void testIsAxesMatchingSpatialCalibrationDifferentScales()
throws Exception
{
// Create a test image with different scales in calibration
final String unit = "mm";
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X, unit, 0.5);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y, unit, 0.6);
final Img<BitType> img = ArrayImgs.bits(1, 1);
final ImgPlus<BitType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis);
final boolean result = IsosurfaceWrapper.isAxesMatchingSpatialCalibration(
imgPlus);
assertFalse(
"Different scales in axes should mean that calibration doesn't match",
result);
}
示例10: testIsAxesMatchingSpatialCalibrationDifferentUnits
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Test
public void testIsAxesMatchingSpatialCalibrationDifferentUnits()
throws Exception
{
// Create a test image with different units in calibration
final double scale = 0.75;
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X, "cm", scale);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y, "mm", scale);
final Img<BitType> img = ArrayImgs.bits(1, 1);
final ImgPlus<BitType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis);
final boolean result = IsosurfaceWrapper.isAxesMatchingSpatialCalibration(
imgPlus);
assertFalse(
"Different units in axes should mean that calibration doesn't match",
result);
}
示例11: testIsAxesMatchingSpatialCalibration
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Test
public void testIsAxesMatchingSpatialCalibration() throws Exception {
// Create a test image with uniform calibration
final String unit = "mm";
final double scale = 0.75;
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X, unit, scale);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y, unit, scale);
final Img<BitType> img = ArrayImgs.bits(1, 1);
final ImgPlus<BitType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis);
final boolean result = IsosurfaceWrapper.isAxesMatchingSpatialCalibration(
imgPlus);
assertTrue("Axes should have matching calibration", result);
}
示例12: testToBitTypeImgPlus
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Test
public void testToBitTypeImgPlus() throws AssertionError {
final String unit = "mm";
final String name = "Test image";
final double scale = 0.5;
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X, unit, scale);
final Img<DoubleType> img = ArrayImgs.doubles(3);
final ImgPlus<DoubleType> source = new ImgPlus<>(img, name, xAxis);
final ImgPlus<BitType> result = Common.toBitTypeImgPlus(IMAGE_J.op(),
source);
final int dimensions = source.numDimensions();
assertEquals("Number of dimensions copied incorrectly", dimensions, result
.numDimensions());
assertTrue("Dimensions copied incorrectly", IntStream.range(0, dimensions)
.allMatch(d -> source.dimension(d) == result.dimension(d)));
assertEquals("Image name was not copied", name, result.getName());
assertEquals("Axis type was not copied", Axes.X, result.axis(0).type());
assertEquals("Axis unit was not copied", unit, result.axis(0).unit());
assertEquals("Axis scale was not copied", scale, result.axis(0)
.averageScale(0, 1), 1e-12);
}
示例13: testCube
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
/**
* Tests the op on a cube. All vectors should enter and exit it, i.e. their
* length should be 0.5.
*/
@Test
public void testCube() {
final Img<BitType> cube = ArrayImgs.bits(100, 100, 100);
final IntervalView<BitType> foreground = Views.interval(cube, new long[] {
1, 1, 1 }, new long[] { 98, 98, 98 });
foreground.cursor().forEachRemaining(BitType::setOne);
final double expectedLength = 1.0 / 2.0;
@SuppressWarnings("unchecked")
final List<Vector3d> milVectors =
(List<Vector3d>) ((ArrayList<Object>) IMAGE_J.op().run(MILGrid.class,
cube, IDENTITY_ROTATION, 10L, DEFAULT_INCREMENT, new Random(0xc0ff33)))
.get(0);
assertEquals("Regression test failed: some vectors have unexpected length",
milVectors.size(), milVectors.stream().filter(v -> v
.length() == expectedLength).count());
}
示例14: testXYSheets
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
/**
* Tests the op with an image of xy-aligned "sheets". Vectors in z-direction
* should be shorter than in x or y.
*/
@Test
public void testXYSheets() {
// SETUP
final int numSheets = 10;
final Vector3d zAxis = new Vector3d(0, 0, 1);
final double expectedZLength = 1.0 / (numSheets * 2);
final Img<BitType> sheets = drawXYSheets();
// EXECUTE
@SuppressWarnings("unchecked")
final List<Vector3d> milVectors =
(List<Vector3d>) ((ArrayList<Object>) IMAGE_J.op().run(MILGrid.class,
sheets, IDENTITY_ROTATION, DEFAULT_BINS, DEFAULT_INCREMENT, new Random(
0xc0ff33))).get(0);
// VERIFY
final Stream<Vector3d> zVectors = milVectors.stream().filter(v -> isParallel
.test(v, zAxis));
assertTrue("MIL vectors in the Z-direction have unexpected length", zVectors
.allMatch(v -> v.length() == expectedZLength));
final Stream<Vector3d> otherVectors = milVectors.stream().filter(
v -> !isParallel.test(v, zAxis));
assertTrue("All MIL vectors in X- Y-directions should have length 1.0",
otherVectors.allMatch(v -> v.length() == 1.0));
}
示例15: testXZSheets
import net.imglib2.type.logic.BitType; //导入依赖的package包/类
@Test
public void testXZSheets() {
// SETUP
final Img<BitType> sheets = ArrayImgs.bits(100, 100, 100);
// Draw 19 XZ sheets
final long numSheets = 19;
for (long y = 5; y < 100; y += 5) {
final IntervalView<BitType> sheet = Views.interval(sheets, new long[] { 0,
y, 0 }, new long[] { 99, y, 99 });
sheet.cursor().forEachRemaining(BitType::setOne);
}
// EXECUTE
@SuppressWarnings("unchecked")
final List<Vector3d> milVectors =
(List<Vector3d>) ((ArrayList<Object>) IMAGE_J.op().run(MILGrid.class,
sheets, IDENTITY_ROTATION, DEFAULT_BINS, DEFAULT_INCREMENT, new Random(
0xc0ff33))).get(0);
// VERIFY
final Stream<Vector3d> yVectors = milVectors.stream().filter(v -> isParallel
.test(v, new Vector3d(0, 1, 0)));
assertTrue("MIL vectors in the Y-direction have unexpected length", yVectors
.allMatch(v -> v.length() == 1.0 / (2 * numSheets)));
}