本文整理汇总了Java中net.imagej.axis.CalibratedAxis类的典型用法代码示例。如果您正苦于以下问题:Java CalibratedAxis类的具体用法?Java CalibratedAxis怎么用?Java CalibratedAxis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CalibratedAxis类属于net.imagej.axis包,在下文中一共展示了CalibratedAxis类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 + ")";
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:33,代码来源:ResultUtils.java
示例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);
});
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:AnisotropyWrapper.java
示例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.");
}
开发者ID:bnanes,项目名称:slideset,代码行数:29,代码来源:AbstractOverlaysToSVGFileWriter.java
示例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);
}
}
}
开发者ID:imagej,项目名称:imagej-ops,代码行数:17,代码来源:MetadataUtil.java
示例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();
}
开发者ID:scifio,项目名称:scifio,代码行数:26,代码来源:AbstractImageMetadata.java
示例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;
}
开发者ID:scifio,项目名称:scifio,代码行数:19,代码来源:AbstractImageMetadata.java
示例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;
}
开发者ID:scifio,项目名称:scifio,代码行数:24,代码来源:AbstractImageMetadata.java
示例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);
}
开发者ID:scifio,项目名称:scifio,代码行数:30,代码来源:DefaultDatasetIOService.java
示例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;
}
开发者ID:scifio,项目名称:scifio,代码行数:19,代码来源:DefaultImgUtilityService.java
示例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);
}
}
开发者ID:scifio,项目名称:scifio,代码行数:17,代码来源:FormatTools.java
示例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);
}
开发者ID:scifio,项目名称:scifio,代码行数:21,代码来源:ImgSaverTest.java
示例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);
}
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:Common.java
示例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;
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:27,代码来源:IsosurfaceWrapper.java
示例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;
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:44,代码来源:ElementUtil.java
示例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;
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:41,代码来源:AxisUtils.java
示例16: countSpatialDimensions
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
/**
* Returns true if the scales of the all the axes can be converted to each
* other
* <p>
* NB Returns true also when all axes are uncalibrated (no units)
* </p>
*/
private static <T extends AnnotatedSpace<CalibratedAxis>> boolean
isUnitsConvertible(T space, final UnitService unitService)
{
final long spatialDimensions = countSpatialDimensions(space);
final long uncalibrated = spatialAxisStream(space).map(CalibratedAxis::unit)
.filter(StringUtils::isNullOrEmpty).count();
if (uncalibrated == spatialDimensions) {
return true;
}
else if (uncalibrated > 0) {
return false;
}
final List<String> units = spatialAxisStream(space).map(
CalibratedAxis::unit).distinct().map(s -> s.replaceFirst("^µ[mM]$", "um"))
.collect(toList());
for (int i = 0; i < units.size(); i++) {
for (int j = i; j < units.size(); j++) {
try {
unitService.value(1.0, units.get(i), units.get(j));
}
catch (Exception e) {
return false;
}
}
}
return true;
}
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:40,代码来源:AxisUtils.java
示例17: addDimensionalAxisInfo
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
private void addDimensionalAxisInfo(final IFD ifd, final int imageIndex) {
// NB: Add dimensional metadata to TIFF comment of first plane's IFD.
final ImageMetadata imageMeta = getMetadata().get(imageIndex);
// Special case axes for ImageJ 1.x compatibility.
final CalibratedAxis cAxis = imageMeta.getAxis(Axes.CHANNEL);
final CalibratedAxis zAxis = imageMeta.getAxis(Axes.Z);
final CalibratedAxis tAxis = imageMeta.getAxis(Axes.TIME);
// All axes, for N-dimensional support.
// NB: Yes, this is a hacky list of parallel lists.
// And yes, we assume that all axes have linear scale.
// This is merely an interim solution until SCIFIO can
// marshal and unmarshal axes in an extensible way.
final List<CalibratedAxis> axes = imageMeta.getAxes();
final String types = list(axes, a -> a.type().toString());
final String lengths = list(axes, a -> "" + imageMeta.getAxisLength(a));
final String scales = list(axes, a -> "" + a.averageScale(0, 1));
final String units = list(axes, a -> replaceMu(a.unit()));
final String comment = "" + //
"SCIFIO=" + getVersion() + "\n" + //
"axes=" + types + "\n" + //
"lengths=" + lengths + "\n" + //
"scales=" + scales + "\n" + //
"units=" + units + "\n" + //
"bitsPerPixel=" + imageMeta.getBitsPerPixel() + "\n" + //
// NB: The following fields are for ImageJ 1.x compatibility.
"images=" + imageMeta.getPlaneCount() + "\n" + //
"channels=" + imageMeta.getAxisLength(cAxis) + "\n" + //
"slices=" + imageMeta.getAxisLength(zAxis) + "\n" + //
"frames=" + imageMeta.getAxisLength(tAxis) + "\n" + //
"hyperstack=true\n" + //
"mode=composite\n" + //
"unit=" + replaceMu(axes.get(0).unit()) + "\n";
ifd.putIFDValue(IFD.IMAGE_DESCRIPTION, comment);
}
开发者ID:scifio,项目名称:scifio,代码行数:38,代码来源:TIFFFormat.java
示例18: setAxisTypes
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
@Override
public void setAxisTypes(final AxisType... axisTypes) {
final CalibratedAxis[] axes = new CalibratedAxis[axisTypes.length];
for (int i = 0; i < axisTypes.length; i++) {
final AxisType t = axisTypes[i];
CalibratedAxis c = getAxis(t);
if (c == null) c = FormatTools.createAxis(t);
axes[i] = c;
}
setAxes(axes);
}
开发者ID:scifio,项目名称:scifio,代码行数:13,代码来源:AbstractImageMetadata.java
示例19: getSize
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
@Override
public long getSize() {
long size = 1;
for (final CalibratedAxis a : getAxes()) {
size = ArrayUtils.safeMultiply64(size, getAxisLength(a));
}
final int bytesPerPixel = getBitsPerPixel() / 8;
return ArrayUtils.safeMultiply64(size, bytesPerPixel);
}
开发者ID:scifio,项目名称:scifio,代码行数:13,代码来源:AbstractImageMetadata.java
示例20: getAxis
import net.imagej.axis.CalibratedAxis; //导入依赖的package包/类
@Override
public CalibratedAxis getAxis(final AxisType axisType) {
for (final CalibratedAxis axis : getAxes()) {
if (axis.type().equals(axisType)) return axis;
}
return null;
}
开发者ID:scifio,项目名称:scifio,代码行数:8,代码来源:AbstractImageMetadata.java
注:本文中的net.imagej.axis.CalibratedAxis类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论