Class StainVector

java.lang.Object
qupath.lib.color.StainVector
All Implemented Interfaces:
Externalizable, Serializable

public class StainVector extends Object implements Externalizable
Representation of a color deconvolution stain vector, defined in terms of RGB optical densities.
Author:
Pete Bankhead
See Also:
  • Constructor Details

    • StainVector

      public StainVector()
      Default constructor, required for Externalizable interface.
  • Method Details

    • makeDefaultStainVector

      public static StainVector makeDefaultStainVector(StainVector.DefaultStains stain)
      Get a default stain vector.
      Parameters:
      stain -
      Returns:
    • createStainVector

      public static StainVector createStainVector(String name, double r, double g, double b)
      Create a stain vector.
      Parameters:
      name - the name of the stain
      r - the stain vector red component
      g - the stain vector green component
      b - the stain vector blue component
      Returns:
    • isResidual

      public boolean isResidual()
      Returns true if this vector represents the residual (orthogonal) stain, used whenever color deconvolution is required with two stains only.
      Returns:
    • getName

      public String getName()
      Returns the name of the stain vector.
      Returns:
    • getRed

      public double getRed()
      Get the red component of the (normalized) stain vector.
      Returns:
    • getGreen

      public double getGreen()
      Get the green component of the (normalized) stain vector.
      Returns:
    • getBlue

      public double getBlue()
      Get the blue component of the (normalized) stain vector.
      Returns:
    • getArray

      public double[] getArray()
      Get the stain vector as a 3 element array (red, green, blue).
      Returns:
    • getColor

      public int getColor()
      Get a Color that (roughly) corresponds to color represented by this stain vector. It may be used to create a color lookup table.
      Returns:
    • arrayAsString

      public String arrayAsString(Locale locale)
      Get a String representation of the stain vector array, formatting according to the specified Locale.
      Parameters:
      locale -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • computeAngle

      public static double computeAngle(StainVector s1, StainVector s2)
      Calculate the angle between two stain vectors, in degrees.
      Parameters:
      s1 -
      s2 -
      Returns:
    • cross3

      public static double[] cross3(double[] u, double[] v)
      Compute the cross product of two vectors.
      Parameters:
      u -
      v -
      Returns:
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException