本文整理汇总了Java中net.imagej.axis.AxisType类的典型用法代码示例。如果您正苦于以下问题:Java AxisType类的具体用法?Java AxisType怎么用?Java AxisType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AxisType类属于net.imagej.axis包,在下文中一共展示了AxisType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LongColumn
import net.imagej.axis.AxisType; //导入依赖的package包/类
/**
* Creates columns for a {@link net.imagej.table.Table} that describe the
* positions of the subspaces in a hyperspace
* <p>
* For example, if you've split a {X, Y, Z, C, T} space into {X, Y, Z}, the
* method returns "Channel" and "Time" columns that list the positions of the
* subspaces in C and T.
* </p>
*
* @see Subspace
* @param subspaces the subspaces of a hyperspace.
* @param <T> type of the elements in the spaces.
* @return columns that list the positions of the subspaces.
* @deprecated only used in tests.
*/
@Deprecated
public static <T extends RealType<T> & NativeType<T>> List<LongColumn>
createCoordinateColumns(List<Subspace<T>> subspaces)
{
final List<LongColumn> coordinateColumns = new ArrayList<>();
if (subspaces == null) {
return coordinateColumns;
}
final AxisType[] types = subspaces.get(0).getAxisTypes().toArray(
AxisType[]::new);
final List<long[]> positions = subspaces.stream().map(s -> s.getPosition()
.toArray()).collect(Collectors.toList());
for (int i = 0; i < types.length; i++) {
final AxisType type = types[i];
final LongColumn coordinateColumn = new LongColumn(type.getLabel());
final int index = i;
positions.stream().mapToLong(p -> toConventionalIndex(type, p[index]))
.forEach(coordinateColumn::add);
coordinateColumns.add(coordinateColumn);
}
return coordinateColumns;
}
示例2: testSplitSubspacesEmptySubspaces
import net.imagej.axis.AxisType; //导入依赖的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());
}
示例3: testSplitSubspacesNoImgPlusMeta
import net.imagej.axis.AxisType; //导入依赖的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());
}
示例4: testSplitSubspacesIdentical
import net.imagej.axis.AxisType; //导入依赖的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);
}
示例5: testSplit3DSubspacesWith2DImgPlus
import net.imagej.axis.AxisType; //导入依赖的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));
});
}
示例6: testSplitSubspacesMultipleSubspaceTypes
import net.imagej.axis.AxisType; //导入依赖的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());
}
示例7: testGetSizeDescription
import net.imagej.axis.AxisType; //导入依赖的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));
}
}
示例8: testGetExponent
import net.imagej.axis.AxisType; //导入依赖的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);
}
}
示例9: testSpatialAxisStream
import net.imagej.axis.AxisType; //导入依赖的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));
}
示例10: onEvent
import net.imagej.axis.AxisType; //导入依赖的package包/类
/**
* When a tool creates an overlay, add the overlay/figure combo to an
* {@link OverlayFigureView}.
*/
@EventHandler
protected void onEvent(final FigureCreatedEvent event) {
final ImageDisplay display = event.getDisplay();
if (display != getDisplay()) return; // not this canvas's display
final OverlayView overlay = event.getView();
for (int i = 0; i < display.numDimensions(); i++) {
final AxisType axisType = display.axis(i).type();
if (axisType.isXY()) continue;
if (overlay.getData().dimensionIndex(axisType) < 0) {
overlay.setPosition(display.getLongPosition(axisType), axisType);
}
}
if (drawingView.getSelectedFigures().contains(event.getFigure())) {
overlay.setSelected(true);
}
final OverlayFigureView figureView =
new OverlayFigureView(displayViewer, overlay, event.getFigure());
figureViews.add(figureView);
display.add(overlay);
display.update();
}
示例11: getAxesIndices
import net.imagej.axis.AxisType; //导入依赖的package包/类
/**
* @param input for which the {@link AxisType}s indices will be determined
* @param axisTypes which will be used to determine the indices
*/
public static synchronized int[] getAxesIndices(final TypedSpace<?> input,
final AxisType[] axisTypes)
{
if (axisTypes == null) return null;
int[] indices = new int[axisTypes.length];
for (int i = 0; i < axisTypes.length; i++) {
indices[i] = input.dimensionIndex(axisTypes[i]);
if (indices[i] == -1) {
// TODO nicer exception handling
throw new IllegalArgumentException(
"AxisType not available in TypedSpace<?>");
}
}
return indices;
}
示例12: getNonPlanarAxisPosition
import net.imagej.axis.AxisType; //导入依赖的package包/类
/**
* Returns the position of the specified {@link AxisType} for the given image
* and plane indices.
*
* @return position of the specified axis type, or 0 if the given axis is
* planar.
*/
public static long getNonPlanarAxisPosition(final Metadata m,
final int imageIndex, final long planeIndex, final AxisType type)
{
final ImageMetadata iMeta = m.get(imageIndex);
int axisIndex = iMeta.getAxisIndex(type);
// Axis is a planar axis
if (axisIndex < iMeta.getPlanarAxisCount()) return 0;
// look up position of the given plane
final long[] position =
rasterToPosition(iMeta.getAxesLengthsNonPlanar(), planeIndex);
// Compute relative index of the desired axis
axisIndex -= iMeta.getPlanarAxisCount();
return position[axisIndex];
}
示例13: getPlaneSize
import net.imagej.axis.AxisType; //导入依赖的package包/类
/** Returns the size in bytes of a w * h tile. */
public static long getPlaneSize(final Metadata m, final int width,
final int height, final int imageIndex)
{
final ImageMetadata iMeta = m.get(imageIndex);
final long[] planeMin = new long[iMeta.getPlanarAxisCount()];
final long[] planeMax = new long[iMeta.getPlanarAxisCount()];
for (int i = 0; i < planeMax.length; i++) {
final AxisType type = iMeta.getAxis(i).type();
if (type == Axes.X) {
planeMax[i] = width;
}
else if (type == Axes.Y) {
planeMax[i] = height;
}
else {
planeMax[i] = iMeta.getAxisLength(type);
}
}
return getPlaneSize(m, planeMin, planeMax, imageIndex);
}
示例14: populateImageMetadata
import net.imagej.axis.AxisType; //导入依赖的package包/类
@Override
public void populateImageMetadata() {
final Metadata m = unwrap();
createImageMetadata(0);
for (int i = 0; i < m.getImageCount(); i++) {
final ImageMetadata iMeta = new DefaultImageMetadata(m.get(i));
// offset to the next axis position
int offset = 0;
for (final AxisType type : splitTypes) {
// For each potentially split axis, if it's a planar axis, move
// it to a
// non-planar position
if (iMeta.getAxisIndex(type) >= 0 &&
iMeta.getAxisIndex(type) < iMeta.getPlanarAxisCount())
{
iMeta.setAxis(iMeta.getPlanarAxisCount() + offset++ - 1, iMeta
.getAxis(type));
iMeta.setPlanarAxisCount(iMeta.getPlanarAxisCount() - 1);
}
}
add(iMeta, false);
}
}
示例15: getCurrentFile
import net.imagej.axis.AxisType; //导入依赖的package包/类
@Override
protected void
setSourceHelper(final String source, final SCIFIOConfig config)
{
final String oldFile = getCurrentFile();
if (!source.equals(oldFile) ||
metaCheck() &&
(((DimensionSwapperMetadata) getMetadata()).getOutputOrder() == null || ((DimensionSwapperMetadata) getMetadata())
.getOutputOrder().length != getImageCount()))
{
@SuppressWarnings("unchecked")
final List<AxisType>[] axisTypeList = new ArrayList[getImageCount()];
((DimensionSwapperMetadata) getMetadata()).setOutputOrder(axisTypeList);
// NB: Create our own copy of the Metadata,
// which we can manipulate safely.
// TODO should be a copy method
if (metaCheck()) ((DimensionSwapperMetadata) getMetadata())
.wrap(getParent().getMetadata());
}
}