Class DualScale<T>

Object
DualScale<T>
Type Parameters:
T - element-type to store.

public class DualScale<T> extends Object
Stores two versions of the same object, representing two different scales.

This is a monad that provides a framework for applying a chain of operations on both scales.

Author:
Owen Feehan
  • Constructor Details

    • DualScale

      public DualScale(T inputScale, T modelScale)
      Creates a new DualScale instance.
      Parameters:
      inputScale - The element scaled to match the size of the input-image.
      modelScale - The element scaled to match the size of the input for model inference.
  • Method Details

    • atInputScale

      public T atInputScale()
      The element scaled to match the size of the input-image.
      Returns:
      the element, at the requested scale.
    • atModelScale

      public T atModelScale()
      The element scaled to match the size of the input for model inference.
      Returns:
      the element, at the requested scale.
    • map

      public <S> DualScale<S> map(Function<T,S> mappingFunction)
      Create a derived DualScale by applying an identical mapping to each element.
      Type Parameters:
      S - the target element-type after the mapping.
      Parameters:
      mappingFunction - maps an instance of type T to type S.
      Returns:
      a newly created DualScale containing the mapped instances.
    • combine

      public <S, U> DualScale<S> combine(DualScale<U> other, BiFunction<T,U,S> combineFunction)
      Create a derived DualScale by combining the respective elements of this instance with another.
      Type Parameters:
      S - the target element-type after combining.
      U - the element-type of other.
      Parameters:
      other - the other DualScale to combine with.
      combineFunction - combines the respective elements from the two DualScales to form an element in the derived instance.
      Returns:
      a newly created DualScale containing the respectiuve outputs from combineFunction.
    • apply

      public <R> R apply(BiFunction<T,T,R> function)
      Apply a BiFunction to both elements.
      Type Parameters:
      R - the return type of the BiFunction.
      Parameters:
      function - the function to apply, to the input-scale and model-scale elements, respectively.
      Returns:
      the result of applying the function to the respective elements.