本文整理汇总了Java中net.imglib2.img.array.ArrayImgs类的典型用法代码示例。如果您正苦于以下问题:Java ArrayImgs类的具体用法?Java ArrayImgs怎么用?Java ArrayImgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArrayImgs类属于net.imglib2.img.array包,在下文中一共展示了ArrayImgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIsAxesMatchingSpatialCalibrationDifferentScales
import net.imglib2.img.array.ArrayImgs; //导入依赖的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);
}
示例2: testIsAxesMatchingSpatialCalibrationDifferentUnits
import net.imglib2.img.array.ArrayImgs; //导入依赖的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);
}
示例3: testIsAxesMatchingSpatialCalibration
import net.imglib2.img.array.ArrayImgs; //导入依赖的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);
}
示例4: test2DImageCancelsPlugin
import net.imglib2.img.array.ArrayImgs; //导入依赖的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());
}
示例5: testSplitSubspacesEmptySubspaces
import net.imglib2.img.array.ArrayImgs; //导入依赖的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());
}
示例6: testSplitSubspacesNoImgPlusMeta
import net.imglib2.img.array.ArrayImgs; //导入依赖的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());
}
示例7: testSplitSubspacesIdentical
import net.imglib2.img.array.ArrayImgs; //导入依赖的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);
}
示例8: testSplit3DSubspacesWith2DImgPlus
import net.imglib2.img.array.ArrayImgs; //导入依赖的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));
});
}
示例9: testSplitSubspacesMultipleSubspaceTypes
import net.imglib2.img.array.ArrayImgs; //导入依赖的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());
}
示例10: testToBitTypeImgPlus
import net.imglib2.img.array.ArrayImgs; //导入依赖的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);
}
示例11: testCube
import net.imglib2.img.array.ArrayImgs; //导入依赖的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());
}
示例12: testXZSheets
import net.imglib2.img.array.ArrayImgs; //导入依赖的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)));
}
示例13: testGetSpatialUnitInconvertibleUnits
import net.imglib2.img.array.ArrayImgs; //导入依赖的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());
}
}
示例14: testGetXYZIndices
import net.imglib2.img.array.ArrayImgs; //导入依赖的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());
}
示例15: testSpatialAxisStream
import net.imglib2.img.array.ArrayImgs; //导入依赖的package包/类
@Test
public void testSpatialAxisStream() throws Exception {
// Create a test image that has spatial axes
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis tAxis = new DefaultLinearAxis(Axes.TIME);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final long[] dimensions = { 10, 3, 10 };
final Img<DoubleType> img = ArrayImgs.doubles(dimensions);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
tAxis, yAxis);
final List<AxisType> result = Streamers.spatialAxisStream(imgPlus).map(
TypedAxis::type).collect(Collectors.toList());
assertNotNull("Stream should not be null", result);
assertEquals("Wrong number of axes in stream", 2, result.size());
assertEquals("Axes in the stream are in wrong order", Axes.X, result.get(
0));
assertEquals("Axes in the stream are in wrong order", Axes.Y, result.get(
1));
}