本文整理汇总了Java中net.imagej.ImgPlus类的典型用法代码示例。如果您正苦于以下问题:Java ImgPlus类的具体用法?Java ImgPlus怎么用?Java ImgPlus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImgPlus类属于net.imagej包,在下文中一共展示了ImgPlus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import net.imagej.ImgPlus; //导入依赖的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: applySplit
import net.imagej.ImgPlus; //导入依赖的package包/类
/**
* Splits a subspace along the given coordinates
* <p>
* For example, if you have a 5D {X, Y, Z, C, T} hyperstack, and give the
* coordinates {{3, 0}, {4, 1}} you'll get a 3D {X, Y, Z} subspace of the
* first channel, and second time frame
* </p>
*
* @param hyperstack an n-dimensional image
* @param splitCoordinates (dimension, position) pairs describing the
* hyperstack split
* @return The subspace interval
*/
private static <T extends RealType<T> & NativeType<T>>
RandomAccessibleInterval<T> applySplit(final ImgPlus<T> hyperstack,
final List<ValuePair<IntType, LongType>> splitCoordinates)
{
final List<ValuePair<IntType, LongType>> workingSplit = createWorkingCopy(
splitCoordinates);
RandomAccessibleInterval<T> slice = hyperstack;
for (int i = 0; i < workingSplit.size(); i++) {
final int dimension = workingSplit.get(i).a.get();
final long position = workingSplit.get(i).b.get();
slice = Views.hyperSlice(slice, dimension, position);
decrementIndices(workingSplit, dimension);
}
return slice;
}
示例3: run
import net.imagej.ImgPlus; //导入依赖的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();
}
}
示例4: run
import net.imagej.ImgPlus; //导入依赖的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();
}
}
示例5: run
import net.imagej.ImgPlus; //导入依赖的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();
}
}
示例6: testIsAxesMatchingSpatialCalibrationDifferentScales
import net.imagej.ImgPlus; //导入依赖的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);
}
示例7: testIsAxesMatchingSpatialCalibrationDifferentUnits
import net.imagej.ImgPlus; //导入依赖的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);
}
示例8: testIsAxesMatchingSpatialCalibration
import net.imagej.ImgPlus; //导入依赖的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);
}
示例9: test2DImageCancelsPlugin
import net.imagej.ImgPlus; //导入依赖的package包/类
public static <C extends Command> void test2DImageCancelsPlugin(
final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
// SETUP
final UserInterface mockUI = mockUIService(imageJ);
// Create an image with only two spatial dimensions
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final DefaultLinearAxis cAxis = new DefaultLinearAxis(Axes.CHANNEL);
final Img<DoubleType> img = ArrayImgs.doubles(10, 10, 3);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis, cAxis);
// EXECUTE
final CommandModule module = imageJ.command().run(commandClass, true,
"inputImage", imgPlus).get();
// VERIFY
assertTrue("2D image should have cancelled the plugin", module
.isCanceled());
assertEquals("Cancel reason is incorrect", CommonMessages.NOT_3D_IMAGE,
module.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例10: testSplitSubspacesEmptySubspaces
import net.imagej.ImgPlus; //导入依赖的package包/类
/**
* Test that subspaces is empty, if we try to split into subspaces that don't
* exist in the stack
*/
@Test
public void testSplitSubspacesEmptySubspaces() throws Exception {
// SETUP
final Img<ByteType> img = ArrayImgs.bytes(2, 2);
final ImgPlus<ByteType> imgPlus = new ImgPlus<>(img, "", X_AXIS, Y_AXIS);
final List<AxisType> subspaceTypes = Collections.singletonList(
Axes.CHANNEL);
// EXECUTE
final Stream<Subspace<ByteType>> subspaces = splitSubspaces(imgPlus,
subspaceTypes);
// VERIFY
assertEquals(0, subspaces.count());
}
示例11: testSplitSubspacesNoImgPlusMeta
import net.imagej.ImgPlus; //导入依赖的package包/类
/**
* Test that subspaces is empty, if we ImgPlus has no metadata about axis
* types
*/
@Test
public void testSplitSubspacesNoImgPlusMeta() throws Exception {
// SETUP
final Img<ByteType> img = ArrayImgs.bytes(2, 2, 2);
final ImgPlus<ByteType> imgPlus = new ImgPlus<>(img, "", BAD_AXIS, BAD_AXIS,
BAD_AXIS);
final List<AxisType> subspaceTypes = Arrays.asList(Axes.X, Axes.Y);
// EXECUTE
final Stream<Subspace<ByteType>> subspaces = splitSubspaces(imgPlus,
subspaceTypes);
// VERIFY
assertEquals(0, subspaces.count());
}
示例12: testSplitSubspacesIdentical
import net.imagej.ImgPlus; //导入依赖的package包/类
/**
* Test that the subspace stream is identical to the input hyperstack, if
* subspace dimensions are equal
*/
@Test
public void testSplitSubspacesIdentical() throws Exception {
// SETUP
final Img<ByteType> img = ArrayImgs.bytes(2, 3);
final AxisType[] types = new AxisType[] { Axes.X, Axes.Y };
final ImgPlus<ByteType> imgPlus = new ImgPlus<>(img, "", types);
// EXECUTE
final List<Subspace<ByteType>> subspaces = splitSubspaces(imgPlus, Arrays
.asList(types)).collect(Collectors.toList());
// VERIFY
assertEquals(1, subspaces.size());
assertEquals(imgPlus, subspaces.get(0).interval);
}
示例13: testSplit3DSubspacesWith2DImgPlus
import net.imagej.ImgPlus; //导入依赖的package包/类
@Test
public void testSplit3DSubspacesWith2DImgPlus() throws Exception {
// SETUP
final long height = 3;
final Img<ByteType> img = ArrayImgs.bytes(2, height);
final ImgPlus<ByteType> imgPlus = new ImgPlus<>(img, "", X_AXIS, Y_AXIS);
final List<AxisType> subspaceTypes = Arrays.asList(Axes.X, Axes.Z);
// EXECUTE
final List<Subspace<ByteType>> subspaces = splitSubspaces(imgPlus,
subspaceTypes).collect(Collectors.toList());
// VERIFY
assertEquals(height, subspaces.size());
subspaces.forEach(s -> {
final List<AxisType> resultTypes = s.getAxisTypes().collect(Collectors
.toList());
assertEquals(1, resultTypes.size());
assertEquals(Axes.Y, resultTypes.get(0));
});
}
示例14: testSplitSubspacesMultipleSubspaceTypes
import net.imagej.ImgPlus; //导入依赖的package包/类
/**
* Test that, for example, if you want a {X, Y, T} subspaces of a {X, Y, Z, T,
* T} hyperstack, the subspaces contain all the time axes. You should get n
* {X, Y, T, T} subspaces, where n is the size of the Z-dimension.
*/
@Test
public void testSplitSubspacesMultipleSubspaceTypes() throws Exception {
// SETUP
final long depth = 5;
final Img<ByteType> img = ArrayImgs.bytes(2, 2, depth, 13, 14);
final ImgPlus<ByteType> imgPlus = new ImgPlus<>(img, "", X_AXIS, Y_AXIS,
Z_AXIS, T_AXIS, T_AXIS);
final List<AxisType> subspaceTypes = Arrays.asList(Axes.X, Axes.Y,
Axes.TIME);
// EXECUTE
final Stream<Subspace<ByteType>> subspaces = splitSubspaces(imgPlus,
subspaceTypes);
// VERIFY
assertEquals(depth, subspaces.count());
}
示例15: testGetSizeDescription
import net.imagej.ImgPlus; //导入依赖的package包/类
@Test
public void testGetSizeDescription() throws Exception {
final String[] expected = { "Size", "Area", "Volume", "Size" };
final AxisType spatialAxis = Axes.get("Spatial", true);
final DefaultLinearAxis axis = new DefaultLinearAxis(spatialAxis);
final ImgPlus mockImage = mock(ImgPlus.class);
when(mockImage.axis(anyInt())).thenReturn(axis);
for (int i = 0; i < expected.length; i++) {
final int dimensions = i + 1;
when(mockImage.numDimensions()).thenReturn(dimensions);
final String description = ResultUtils.getSizeDescription(mockImage);
assertTrue("Size description is incorrect", expected[i].equals(
description));
}
}