java.lang.Object
qupath.bioimageio.spec.tensor.Shape
- Direct Known Subclasses:
Shape.ImplicitOutputShape,Shape.ParameterizedInputShape,Shape.SizesShape
Shape of input or output tensor.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA shape that is determined based on the shape of another tensor.static classA shape that is determined based on a minimum and a step size.static classA Shape that wraps tensor Size objects from the 0.5 spec. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]createShapeArray(String axes, Map<Character, Integer> target, int defaultLength) Create a shape array for a given axes.intGet the number of elements in the shape array.double[]Get the shape scale, useful for implicit shapes.double[]getScale()Get the shape scale, useful for implicit shapes.int[]getShape()Get the shape, if this is defined explicitly.int[]Get the minimum shape; useful for parameterized shapes.int[]Get the shape step (increment), useful for parameterized shapes.int[]getTargetShape(int... target) Get a compatible shape given the specified target.toString()
-
Field Details
-
shape
protected int[] shape
-
-
Constructor Details
-
Shape
public Shape()
-
-
Method Details
-
createShapeArray
Create a shape array for a given axes. The axes are expected to a string containing only the charactersbitczyxas defined in the spec.The purpose of this is to build shape arrays easily without needing to explicitly handle different axes and dimension ordering.
An example:
int[] shape = createShapeArray("byxc", Map.of('x', 256, 'y', 512), 1);This should result in an int array with values
[1, 512, 256, 1].- Parameters:
axes- the axes stringtarget- map defining the intended length for specified dimensionsdefaultLength- the default length to use for any dimension that are not included in the target map- Returns:
- an int array with the same length as the axes string, containing the requested dimensions or default values
-
getShape
public int[] getShape()Get the shape, if this is defined explicitly. UsuallygetTargetShape(int...)is more useful.- Returns:
- The shape in pixels.
-
getShapeMin
public int[] getShapeMin()Get the minimum shape; useful for parameterized shapes.- Returns:
- An int array of minimum shape sizes.
-
getTargetShape
public int[] getTargetShape(int... target) Get a compatible shape given the specified target.For an explicit shape (without scale/offset/step etc.) the target does not influence the result.
- Parameters:
target- The shape (in pixel width/height/etc.) in pixels that we are requesting.- Returns:
- As close to the shape as the Shape object allows if a parameterized shape, or the fixed shape if fixed.
-
getLength
public int getLength()Get the number of elements in the shape array.- Returns:
- The number of elements in the shape array.
-
getShapeStep
public int[] getShapeStep()Get the shape step (increment), useful for parameterized shapes.- Returns:
- An int array of shape steps.
-
getScale
public double[] getScale()Get the shape scale, useful for implicit shapes.- Returns:
- A double array of scales.
-
getOffset
public double[] getOffset()Get the shape scale, useful for implicit shapes.- Returns:
- A double array of offsets.
-
toString
-