Class CodomainChain


  • public class CodomainChain
    extends java.lang.Object
    Queues the contexts that define the spatial domain transformations that have to be applied to the image.

    A lookup table is built by composing all maps (in the same order as their contexts were enqueued) in a single transformation and then by applying this map to each value in the codomain interval [intervalStart, intervalEnd] — note that, in order to compose the maps, this interval has to be both the domain and codomain of each transformation. The LUT is re-built every time the definition of the codomain interval or the state of the queue changes.

    Contexts are privately owned (add and update make copies) because we want to exclude the possibility that a context's state can be modified after the lookup table is built.

    Since:
    OME2.2
    • Constructor Summary

      Constructors 
      Constructor Description
      CodomainChain​(int start, int end)
      Creates a new chain.
      CodomainChain​(int start, int end, java.util.List<omeis.providers.re.codomain.CodomainMapContext> mapContexts)
      Creates a new chain.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(omeis.providers.re.codomain.CodomainMapContext mapCtx)
      Adds a map context to the chain.
      java.util.List<omeis.providers.re.codomain.CodomainMapContext> getContexts()
      Returns a copy of the codomain context if any.
      int getIntervalEnd()
      Returns the upper bound of the codomain interval.
      int getIntervalStart()
      Returns the lower bound of the codomain interval.
      boolean hasMapContext()
      Returns true if some transformations need to be applied, false otherwise.
      void remove()
      Removes all CodomainMapContexts except the identity and resets the interval.
      boolean remove​(omeis.providers.re.codomain.CodomainMapContext mapCtx)
      Removes a map context from the chain.
      void setInterval​(int start, int end)
      Sets the codomain interval.
      java.lang.String toString()
      Overrides the toString method.
      int transform​(int x)
      Applies the transformation.
      void update​(omeis.providers.re.codomain.CodomainMapContext mapCtx)
      Updates a map context in the chain.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CodomainChain

        public CodomainChain​(int start,
                             int end)
        Creates a new chain. The chain will contain the identity context. So if no transformation is added, the transform method returns the input value. The interval defined by start and end must be a sub-interval of [QuantumStrategy.MIN, QuantumStrategy.MAX].
        Parameters:
        start - The lower bound of the codomain interval.
        end - The upper bound of the codomain interval.
      • CodomainChain

        public CodomainChain​(int start,
                             int end,
                             java.util.List<omeis.providers.re.codomain.CodomainMapContext> mapContexts)
        Creates a new chain. The chain will contain the specified contexts — if mapContexts is null or empty, the chain will contain only the identity context. The interval defined by start and end has to be a sub-interval of [QuantumStrategy.MIN, QuantumStrategy.MAX].
        Parameters:
        start - The lower bound of the codomain interval.
        end - The upper bound of the codomain interval.
        mapContexts - The sequence of CodomainMapContext objects that define the chain. No two objects of the same class are allowed. The objects in this list are copied.
        Throws:
        java.lang.IllegalArgumentException - If one of the contexts is already defined.
    • Method Detail

      • setInterval

        public void setInterval​(int start,
                                int end)
        Sets the codomain interval. This triggers an update of all map contexts in the chain and a re-build of the lookup table. The interval defined by start and end must be a sub-interval of [QuantumStrategy.MIN, QuantumStrategy.MAX].
        Parameters:
        start - The lower bound of the codomain interval.
        end - The upper bound of the codomain interval.
      • getIntervalEnd

        public int getIntervalEnd()
        Returns the upper bound of the codomain interval.
        Returns:
        See above.
      • getIntervalStart

        public int getIntervalStart()
        Returns the lower bound of the codomain interval.
        Returns:
        See above.
      • remove

        public void remove()
        Removes all CodomainMapContexts except the identity and resets the interval.
      • add

        public boolean add​(omeis.providers.re.codomain.CodomainMapContext mapCtx)
        Adds a map context to the chain. This means that the transformation associated to the passed context will be applied after all the currently queued transformations. An exception will be thrown if the chain already contains an object of the same class as mapCtx. This is because we don't want to compose the same transformation twice. This method adds a copy of mapCtx to the chain. This is because we want to exclude the possibility that the context's state can be modified after the lookup table is built. This method triggers a re-build of the lookup table.
        Parameters:
        mapCtx - The context to add. Mustn't be null.
        Returns:
        Return true if the context was added, false otherwise.
      • update

        public void update​(omeis.providers.re.codomain.CodomainMapContext mapCtx)
        Updates a map context in the chain. An exception will be thrown if the chain doesn't contain an object of the same class as mapCtx. This method replaces the old context with a copy of mapCtx. This is because we want to exclude the possibility that the context's state can be modified after the lookup table is built. This method triggers a re-build of the lookup table.
        Parameters:
        mapCtx - The context to add. Mustn't be null and already contained in the chain.
        Throws:
        java.lang.IllegalArgumentException - If the specified context doesn't exist.
      • remove

        public boolean remove​(omeis.providers.re.codomain.CodomainMapContext mapCtx)
        Removes a map context from the chain. This method removes the object (if any) in the chain that is an instance of the same class as mapCtx. This means that the transformation associated to the passed context won't be applied. This method triggers a re-build of the lookup table.
        Parameters:
        mapCtx - The context to remove.
        Returns:
        Returns true if the chain was removed, false otherwise.
      • transform

        public int transform​(int x)
        Applies the transformation. This transformation is the result of the composition of all maps defined by the current chain. Composition follows the chain order.
        Parameters:
        x - The input value. Must be in the current codomain interval.
        Returns:
        The output value, y.
      • hasMapContext

        public boolean hasMapContext()
        Returns true if some transformations need to be applied, false otherwise.
        Returns:
        See above.
      • getContexts

        public java.util.List<omeis.providers.re.codomain.CodomainMapContext> getContexts()
        Returns a copy of the codomain context if any.
        Returns:
        See above.
      • toString

        public java.lang.String toString()
        Overrides the toString method.
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()