本文整理汇总了Java中net.imagej.axis.CalibratedAxis类的典型用法代码示例。如果您正苦于以下问题:Java CalibratedAxis类的具体用法?Java CalibratedAxis怎么用?Java CalibratedAxis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CalibratedAxis类属于net.imagej.axis包,在下文中一共展示了CalibratedAxis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnitHeader
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/**
* Returns the common unit string, e.g. "mm<sup>3</sup>" that describes the
* elements in the space.
* <p>
* The common unit is the unit of the first spatial axis if it can be
* converted to the units of the other axes.
* </p>
*
* @param space an N-dimensional space.
* @param <S> type of the space.
* @param unitService an {@link UnitService} to convert axis calibrations.
* @param exponent an exponent to be added to the unit, e.g. '³'.
* @return the unit string with the exponent.
*/
public static <S extends AnnotatedSpace<CalibratedAxis>> String getUnitHeader(
final S space, final UnitService unitService, final char exponent)
{
final Optional<String> unit = AxisUtils.getSpatialUnit(space, unitService);
if (!unit.isPresent()) {
return "";
}
final String unitHeader = unit.get();
if ("pixel".equalsIgnoreCase(unitHeader) || "unit".equalsIgnoreCase(
unitHeader) || unitHeader.isEmpty())
{
// Don't show default units
return "";
}
return "(" + unitHeader + exponent + ")";
}
示例2: applyCalibration
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
private void applyCalibration(final List<Vector3d> pointCloud) {
final double[] scales = spatialAxisStream(inputImage).mapToDouble(
axis -> axis.averageScale(0, 1)).toArray();
final String[] units = spatialAxisStream(inputImage).map(
CalibratedAxis::unit).toArray(String[]::new);
final double yxConversion = unitService.value(1.0, units[1], units[0]);
final double zxConversion = unitService.value(1.0, units[2], units[0]);
final double xScale = scales[0];
final double yScale = scales[1] * yxConversion;
final double zScale = scales[2] * zxConversion;
pointCloud.forEach(p -> {
p.setX(p.x * xScale);
p.setY(p.y * yScale);
p.setZ(p.z * zScale);
});
}
示例3: getPlanarAxes
import net.imagej.axis.CalibratedAxis; //导入依赖的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.");
}
示例4: copyTypedSpace
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <C extends CalibratedAxis> void copyTypedSpace(
final Interval inInterval, final CalibratedSpace<C> in,
final CalibratedSpace<C> out)
{
int offset = 0;
for (int d = 0; d < in.numDimensions(); d++) {
if (inInterval != null && inInterval.dimension(d) == 1) {
offset++;
}
else {
out.setAxis((C) in.axis(d).copy(), d - offset);
}
}
}
示例5: setAxis
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
@Override
public void setAxis(final int index, final CalibratedAxis axis) {
final int oldIndex = getAxisIndex(axis);
// Replace existing axis
if (oldIndex < 0) {
final long length = axisLengths.remove(axes.get(index).type());
axes.remove(index);
if (index == axes.size()) {
axes.add(axis);
}
else {
axes.add(index, axis);
}
axisLengths.put(axis.type(), length);
}
// Axis is already in the list. Move it here.
else {
axes.remove(axes.get(oldIndex));
axes.add(index, axis);
}
clearCachedAxes();
}
示例6: populate
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
@Override
public void populate(final String name, final List<CalibratedAxis> axes,
final long[] lengths, final int pixelType, final int bitsPerPixel,
final boolean orderCertain, final boolean littleEndian,
final boolean indexed, final boolean falseColor,
final boolean metadataComplete)
{
// FIXME: Use setters, not direct assignment.
this.name = name;
this.axes = new ArrayList<>(axes);
setAxisLengths(lengths.clone());
this.bitsPerPixel = bitsPerPixel;
this.falseColor = falseColor;
this.indexed = indexed;
this.littleEndian = littleEndian;
this.orderCertain = orderCertain;
this.pixelType = pixelType;
}
示例7: getEffectiveAxes
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/**
* Computes and caches the effective (non-trailing-length-1 axes) axis types
* for this dataset.
*/
private List<CalibratedAxis> getEffectiveAxes() {
if (effectiveAxes == null && axes != null) {
int end = axes.size();
for (; end > getPlanarAxisCount(); end--) {
final CalibratedAxis axis = axes.get(end - 1);
if (getAxisLength(axis) > 1) {
break;
}
}
effectiveAxes = new ArrayList<>();
for (int i = 0; i < end; i++) {
effectiveAxes.add(axes.get(i));
}
}
return effectiveAxes;
}
示例8: updateDataset
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/**
* The {@link DatasetService#create} methods make a best guess for populating
* {@link Dataset} information. But this can be incorrect/over-aggressive,
* e.g. in the case of RGBMerged state.
* <p>
* If we have access to the {@link Metadata} instance backing a
* {@code Dataset}, we can use it to more accurately populate these settings.
* </p>
*
* @param dataset Dataset instance to update.
* @param imageMeta Metadata instance to query for updated information.
*/
private void updateDataset(final Dataset dataset,
final ImageMetadata imageMeta)
{
// If the original image had some level of merged channels, we should set
// RGBmerged to true for the sake of backwards compatibility.
// See https://github.com/imagej/imagej-legacy/issues/104
// Look for Axes.CHANNEL in the planar axis list. If found, set RGBMerged to
// true.
boolean rgbMerged = false;
for (final CalibratedAxis axis : imageMeta.getAxesPlanar()) {
if (axis.type().equals(Axes.CHANNEL)) rgbMerged = true;
}
dataset.setRGBMerged(rgbMerged);
}
示例9: getConstrainedLengths
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
@Override
public long[] getConstrainedLengths(final Metadata m, final int imageIndex,
final SCIFIOConfig config)
{
final long[] lengths = getDimLengths(m, imageIndex, config);
final ImageRegion r = config.imgOpenerGetRegion();
if (r != null) {
// set each dimension length = the number of entries for that axis
for (final CalibratedAxis t : m.get(0).getAxes()) {
final Range range = r.getRange(t.type());
if (range != null) lengths[m.get(0).getAxisIndex(t)] = range.size();
}
}
return lengths;
}
示例10: checkTileSize
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/** Checks that the given tile size is valid for the given reader. */
public static void checkTileSize(final Metadata m, final long[] planeMin,
final long[] planeMax, final int imageIndex) throws FormatException
{
final List<CalibratedAxis> axes = m.get(imageIndex).getAxesPlanar();
for (int i = 0; i < axes.size(); i++) {
final long start = planeMin[i];
final long end = planeMax[i];
final long length = m.get(imageIndex).getAxisLength(axes.get(i));
if (start < 0 || end < 0 || (start + end) > length) throw new FormatException(
"Invalid planar size: start=" + start + ", end=" + end +
", length in metadata=" + length);
}
}
示例11: assertImagesEqual
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
private static <T> void assertImagesEqual(final ImgPlus<T> expected,
final ImgPlus<T> actual)
{
// check dimensional lengths
final long[] eDims = new long[expected.numDimensions()];
expected.dimensions(eDims);
final long[] aDims = new long[actual.numDimensions()];
actual.dimensions(aDims);
assertArrayEquals(eDims, aDims);
// check dimensional axes
final CalibratedAxis[] eAxes = new CalibratedAxis[expected.numDimensions()];
expected.axes(eAxes);
final CalibratedAxis[] aAxes = new CalibratedAxis[actual.numDimensions()];
actual.axes(aAxes);
assertArrayEquals(eAxes, aAxes);
// check pixels
assertIterationsEqual(expected, actual);
}
示例12: copyMetadata
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/**
* Copies image metadata such as name, axis types and calibrations from source
* to target.
*
* @param source source of metadata.
* @param target target of metadata.
*/
private static void copyMetadata(ImgPlus<?> source, ImgPlus<?> target) {
target.setName(source.getName());
final int dimensions = source.numDimensions();
for (int d = 0; d < dimensions; d++) {
final CalibratedAxis axis = source.axis(d);
target.setAxis(axis, d);
}
}
示例13: spatialAxisStream
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/**
* Check if all the spatial axes have a matching calibration, e.g. same unit,
* same scaling.
* <p>
* NB: Public and static for testing purposes.
* </p>
*
* @param space an N-dimensional space.
* @param <T> type of the space
* @return true if all spatial axes have matching calibration. Also returns
* true if none of them have a unit
*/
// TODO make into a utility method or remove if mesh area considers
// calibration in the future
public static <T extends AnnotatedSpace<CalibratedAxis>> boolean
isAxesMatchingSpatialCalibration(T space)
{
final boolean noUnits = spatialAxisStream(space).map(CalibratedAxis::unit)
.allMatch(StringUtils::isNullOrEmpty);
final boolean matchingUnit = spatialAxisStream(space).map(
CalibratedAxis::unit).distinct().count() == 1;
final boolean matchingScale = spatialAxisStream(space).map(a -> a
.averageScale(0, 1)).distinct().count() == 1;
return (matchingUnit || noUnits) && matchingScale;
}
示例14: if
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/**
* Returns the calibrated size of a single spatial element in the given space,
* e.g. the volume of an element in a 3D space, or area in 2D.
* <p>
* Spatial axes do not have to have the same unit in calibration, but you must
* be able to convert between them.
* </p>
*
* @param space an N-dimensional space.
* @param <T> type of the space.
* @param unitService needed to convert between units of different
* calibrations.
* @return Calibrated size of a spatial element, or Double.NaN if space ==
* null, has nonlinear axes, or calibration units don't match.
*/
public static <T extends AnnotatedSpace<CalibratedAxis>> double
calibratedSpatialElementSize(final T space, final UnitService unitService)
{
final Optional<String> optional = AxisUtils.getSpatialUnit(space, unitService);
if (!optional.isPresent() || AxisUtils.hasNonLinearSpatialAxes(space)) {
return Double.NaN;
}
final String unit = optional.get().replaceFirst("^µ[mM]$", "um");
if (unit.isEmpty()) {
return uncalibratedSize(space);
}
final List<CalibratedAxis> axes = spatialAxisStream(space).collect(
Collectors.toList());
double elementSize = axes.get(0).averageScale(0.0, 1.0);
for (int i = 1; i < axes.size(); i++) {
double scale = axes.get(i).averageScale(0.0, 1.0);
final String axisUnit = axes.get(i).unit().replaceFirst("^µ[mM]$", "um");
try {
final double axisSize = unitService.value(scale, axisUnit, unit);
elementSize *= axisSize;
} catch (Exception e) {
return uncalibratedSize(space);
}
}
return elementSize;
}
示例15: spatialAxisStream
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/**
* Determines the coefficient to convert units from the spatial axis with the
* smallest calibration to the largest.
*
* @param scale scale of the first spatial axis.
* @param unit unit of the first spatial axis.
* @param space an n-dimensional space with calibrated axes.
* @param <S> type of the space.
* @param unitService an {@link UnitService} to convert axis calibrations.
* @return greatest conversion coefficient between two axes found. Coefficient
* == 0.0 if space == null, or there are no spatial axes.
* @deprecated only used in test code.
*/
@Deprecated
public static <S extends AnnotatedSpace<CalibratedAxis>> double
getMaxConversion(final double scale, final String unit,
final S space, final UnitService unitService)
{
final List<CalibratedAxis> axes = spatialAxisStream(space).collect(
toList());
double maxConversion = 0.0;
for (CalibratedAxis axis : axes) {
final double axisScale = axis.averageScale(0.0, 1.0);
final String axisUnit = axis.unit().replaceFirst("^µ[mM]$", "um");
final double toConversion = scale * unitService.value(1.0, unit,
axisUnit) / axisScale;
final double fromConversion = axisScale * unitService.value(1.0, axisUnit,
unit) / scale;
final double conversion = toConversion >= fromConversion ? toConversion
: fromConversion;
if (conversion >= maxConversion) {
maxConversion = conversion;
}
}
return maxConversion;
}