java.lang.Object
qupath.bioimageio.spec.tensor.Shape
Direct Known Subclasses:
Shape.ImplicitOutputShape, Shape.ParameterizedInputShape, Shape.SizesShape

public class Shape extends Object
Shape of input or output tensor.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A shape that is determined based on the shape of another tensor.
    static class 
    A shape that is determined based on a minimum and a step size.
    static class 
    A Shape that wraps tensor Size objects from the 0.5 spec.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    createShapeArray(String axes, Map<Character,Integer> target, int defaultLength)
    Create a shape array for a given axes.
    int
    Get the number of elements in the shape array.
    double[]
    Get the shape scale, useful for implicit shapes.
    double[]
    Get the shape scale, useful for implicit shapes.
    int[]
    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.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • shape

      protected int[] shape
  • Constructor Details

    • Shape

      public Shape()
  • Method Details

    • createShapeArray

      public static int[] createShapeArray(String axes, Map<Character,Integer> target, int defaultLength)
      Create a shape array for a given axes. The axes are expected to a string containing only the characters bitczyx as 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 string
      target - map defining the intended length for specified dimensions
      defaultLength - 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. Usually getTargetShape(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

      public String toString()
      Overrides:
      toString in class Object