本文整理汇总了Java中net.imagej.ImgPlus类的典型用法代码示例。如果您正苦于以下问题:Java ImgPlus类的具体用法?Java ImgPlus怎么用?Java ImgPlus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImgPlus类属于net.imagej包,在下文中一共展示了ImgPlus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:21,代码来源:ConnectivityWrapper.java
示例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;
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:29,代码来源:HyperstackUtils.java
示例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();
}
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:21,代码来源:IsosurfaceWrapper.java
示例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();
}
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:21,代码来源:SurfaceFractionWrapper.java
示例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();
}
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:19,代码来源:ElementFractionWrapper.java
示例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);
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:IsosurfaceWrapperTest.java
示例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);
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:IsosurfaceWrapperTest.java
示例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);
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:IsosurfaceWrapperTest.java
示例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());
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:26,代码来源:CommonWrapperTests.java
示例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());
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:HyperstackUtilsTest.java
示例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());
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:HyperstackUtilsTest.java
示例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);
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:HyperstackUtilsTest.java
示例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));
});
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:22,代码来源:HyperstackUtilsTest.java
示例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());
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:23,代码来源:HyperstackUtilsTest.java
示例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));
}
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:19,代码来源:ResultUtilsTest.java
示例16: testGetExponent
import net.imagej.ImgPlus; //导入依赖的package包/类
@Test
public void testGetExponent() throws Exception {
final char[] expected = { '\u0000', '\u00B2', '\u00B3', '\u2074', '\u2075',
'\u2076', '\u2077', '\u2078', '\u2079', '\u0000' };
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 char exponent = ResultUtils.getExponent(mockImage);
assertEquals("Wrong exponent character", expected[i], exponent);
}
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:19,代码来源:ResultUtilsTest.java
示例17: testToBitTypeImgPlus
import net.imagej.ImgPlus; //导入依赖的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);
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:24,代码来源:CommonTest.java
示例18: calculate
import net.imagej.ImgPlus; //导入依赖的package包/类
@Override
public ImgPlus<BitType> calculate() {
final ImgPlus<BitType> cuboid = createIJ1ImgPlus("Hollow cuboid", xSize,
ySize, zSize, channels, frames, padding, scale, unit);
final RandomAccess<BitType> access = cuboid.randomAccess();
for (int t = 0; t < frames; t++) {
access.setPosition(t, TIME_DIM);
for (int c = 0; c < channels; c++) {
access.setPosition(c, CHANNEL_DIM);
drawFaces(access, X_DIM, Y_DIM, Z_DIM, xSize, ySize, zSize);
drawFaces(access, X_DIM, Z_DIM, Y_DIM, xSize, zSize, ySize);
drawFaces(access, Y_DIM, Z_DIM, X_DIM, ySize, zSize, xSize);
}
}
return cuboid;
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:19,代码来源:HollowCuboid.java
示例19: testGetSpatialUnitInconvertibleUnits
import net.imagej.ImgPlus; //导入依赖的package包/类
@Test
public void testGetSpatialUnitInconvertibleUnits() throws Exception {
final String[][] units = { { "m", "" }, { "cm", "kg" } };
final Img<ByteType> img = ArrayImgs.bytes(1, 1);
final ImgPlus<ByteType> imgPlus = new ImgPlus<>(img);
for (final String[] unit : units) {
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X, unit[0]);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y, unit[1]);
imgPlus.setAxis(xAxis, 0);
imgPlus.setAxis(yAxis, 1);
final Optional<String> result = AxisUtils.getSpatialUnit(imgPlus,
unitService);
assertTrue(result.isPresent());
assertTrue("Unit should be empty", result.get().isEmpty());
}
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:AxisUtilsTest.java
示例20: testGetXYZIndices
import net.imagej.ImgPlus; //导入依赖的package包/类
@Test
public void testGetXYZIndices() throws Exception {
final int[] expectedIndices = { 0, 1, 3 };
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final DefaultLinearAxis cAxis = new DefaultLinearAxis(Axes.CHANNEL);
final DefaultLinearAxis zAxis = new DefaultLinearAxis(Axes.Z);
final Img<DoubleType> img = ArrayImgs.doubles(1, 1, 1, 1);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis, cAxis, zAxis);
final Optional<int[]> result = AxisUtils.getXYZIndices(imgPlus);
assertTrue("Optional should be present", result.isPresent());
assertArrayEquals("Indices are incorrect", expectedIndices, result.get());
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:AxisUtilsTest.java
注:本文中的net.imagej.ImgPlus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论