本文整理汇总了Java中net.imagej.axis.Axes类的典型用法代码示例。如果您正苦于以下问题:Java Axes类的具体用法?Java Axes怎么用?Java Axes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Axes类属于net.imagej.axis包,在下文中一共展示了Axes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testIsAxesMatchingSpatialCalibrationDifferentScales
import net.imagej.axis.Axes; //导入依赖的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
示例2: testIsAxesMatchingSpatialCalibrationDifferentUnits
import net.imagej.axis.Axes; //导入依赖的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
示例3: testIsAxesMatchingSpatialCalibration
import net.imagej.axis.Axes; //导入依赖的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
示例4: test2DImageCancelsPlugin
import net.imagej.axis.Axes; //导入依赖的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
示例5: testSplitSubspacesEmptySubspaces
import net.imagej.axis.Axes; //导入依赖的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
示例6: testSplitSubspacesNoImgPlusMeta
import net.imagej.axis.Axes; //导入依赖的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
示例7: testSplitSubspacesIdentical
import net.imagej.axis.Axes; //导入依赖的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
示例8: testSplit3DSubspacesWith2DImgPlus
import net.imagej.axis.Axes; //导入依赖的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
示例9: testSplitSubspacesMultipleSubspaceTypes
import net.imagej.axis.Axes; //导入依赖的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
示例10: testGetSizeDescription
import net.imagej.axis.Axes; //导入依赖的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
示例11: testGetExponent
import net.imagej.axis.Axes; //导入依赖的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
示例12: testToBitTypeImgPlus
import net.imagej.axis.Axes; //导入依赖的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
示例13: testGetSpatialUnitInconvertibleUnits
import net.imagej.axis.Axes; //导入依赖的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
示例14: testGetXYZIndices
import net.imagej.axis.Axes; //导入依赖的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
示例15: testSpatialAxisStream
import net.imagej.axis.Axes; //导入依赖的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));
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:22,代码来源:StreamersTest.java
示例16: getPlanarAxes
import net.imagej.axis.Axes; //导入依赖的package包/类
/**
* Get the X and Y axis indeces for an overlay
* @param axes A 2-element {@code int} array that
* will be filled with the X and Y axis indeces,
* in that order.
*/
private void getPlanarAxes(
AbstractOverlay overlay,
int[] axes)
throws SlideSetException {
if(axes == null || axes.length != 2)
throw new SlideSetException(
"Need an array to return exactly two integers.");
CalibratedAxis[] axs = new CalibratedAxis[overlay.numDimensions()];
overlay.axes(axs);
if(axs == null || axs.length == 0)
throw new UnsupportedOverlayException("No axes found!");
axes[0] = -1;
axes[1] = -1;
for(int i=0; i < axs.length; i++) {
if(axs[i].type() == Axes.X)
axes[0] = i;
else if(axs[i].type() == Axes.Y)
axes[1] = i;
}
if(axes[0] < 0 || axes[1] < 0)
throw new UnsupportedOverlayException("Missing X or Y axis.");
}
开发者ID:bnanes,项目名称:slideset,代码行数:29,代码来源:AbstractOverlaysToSVGFileWriter.java
示例17: parsePolygon
import net.imagej.axis.Axes; //导入依赖的package包/类
/** Generate an overlay from a {@code polygon} element */
private AbstractOverlay parsePolygon(Element n) throws SVGParseException {
if(!"polygon".equals(n.getTagName()))
throw new SVGParseException("\'polygon\' expected, but \'" + n.getLocalName() + "\' found.");
String points = n.getAttribute("points");
ArrayList<double[]> pts;
try {
pts = parseListOfPoints(points);
} catch(NumberFormatException e) {
throw new SVGParseException("Bad points list: " + points, e);
}
if(pts.isEmpty())
return null;
PolygonOverlay po = new PolygonOverlay(ij);
po.setAxis(new DefaultLinearAxis(Axes.X), 0);
po.setAxis(new DefaultLinearAxis(Axes.Y), 1);
PolygonRegionOfInterest poi = po.getRegionOfInterest();
for(double[] pt : pts) {
int i = poi.getVertexCount();
poi.addVertex(i, new RealPoint(transformToDocumentSpace(pt, n)));
}
return po;
}
开发者ID:bnanes,项目名称:slideset,代码行数:24,代码来源:SVGFileToAbstractOverlayReader.java
示例18: isNearBorder
import net.imagej.axis.Axes; //导入依赖的package包/类
/** Handler for {@code PolygonOverlay}s */
public static boolean isNearBorder(
final double[] P,
final PolygonOverlay overlay,
final double radius) {
final int x = overlay.dimensionIndex(Axes.X);
final int y = overlay.dimensionIndex(Axes.Y);
if(x < 0 || y < 0)
throw new IllegalArgumentException("Overlay must have x and y axes.");
final PolygonRegionOfInterest roi = overlay.getRegionOfInterest();
final int n = roi.getVertexCount();
final double[] vertex = new double[roi.numDimensions()];
final double[][] vertices = new double[n][2];
for(int i = 0; i < n; i++) {
roi.getVertex(i).localize(vertex);
vertices[i][0] = vertex[x];
vertices[i][1] = vertex[y];
}
return isNearBorder(P, vertices, radius, true);
}
开发者ID:bnanes,项目名称:slideset,代码行数:21,代码来源:RoiUtils.java
示例19: openThumbPlane
import net.imagej.axis.Axes; //导入依赖的package包/类
@Override
public ByteArrayPlane openThumbPlane(final int imageIndex,
final long planeIndex) throws FormatException, IOException
{
FormatTools.assertStream(getStream(), true, 1);
final Metadata meta = getMetadata();
final long[] planeBounds = meta.get(imageIndex).getAxesLengthsPlanar();
final long[] planeOffsets = new long[planeBounds.length];
planeBounds[meta.get(imageIndex).getAxisIndex(Axes.X)] =
meta.get(imageIndex).getThumbSizeX();
planeBounds[meta.get(imageIndex).getAxisIndex(Axes.Y)] =
meta.get(imageIndex).getThumbSizeX();
final ByteArrayPlane plane = createPlane(planeOffsets, planeBounds);
plane.setData(FormatTools.openThumbBytes(this, imageIndex, planeIndex));
return plane;
}
开发者ID:scifio,项目名称:scifio,代码行数:21,代码来源:ByteArrayReader.java
示例20: populateImageMetadata
import net.imagej.axis.Axes; //导入依赖的package包/类
@Override
public void populateImageMetadata() {
final ImageMetadata iMeta = get(0);
if (img != null) {
iMeta.setAxisLength(Axes.X, img.getWidth());
iMeta.setAxisLength(Axes.Y, img.getHeight());
iMeta.setPlanarAxisCount(2);
final int channels = img.getRaster().getNumBands();
if (channels > 1) {
iMeta.setPlanarAxisCount(3);
iMeta.setAxisLength(Axes.CHANNEL, img.getRaster().getNumBands());
}
iMeta.setPixelType(AWTImageTools.getPixelType(img));
}
iMeta.setLittleEndian(false);
iMeta.setMetadataComplete(true);
iMeta.setIndexed(false);
iMeta.setFalseColor(false);
}
开发者ID:scifio,项目名称:scifio,代码行数:22,代码来源:ImageIOFormat.java
注:本文中的net.imagej.axis.Axes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论