Package qupath.lib.color
Class StainVector
java.lang.Object
qupath.lib.color.StainVector
- All Implemented Interfaces:
Externalizable,Serializable
Representation of a color deconvolution stain vector, defined in terms of RGB optical densities.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing default stains. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarrayAsString(Locale locale) Get a String representation of the stain vector array, formatting according to the specified Locale.static doublecomputeAngle(StainVector s1, StainVector s2) Calculate the angle between two stain vectors, in degrees.static StainVectorcreateStainVector(String name, double r, double g, double b) Create a stain vector.static double[]cross3(double[] u, double[] v) Compute the cross product of two vectors.booleandouble[]getArray()Get the stain vector as a 3 element array (red, green, blue).doublegetBlue()Get the blue component of the (normalized) stain vector.intgetColor()Get a Color that (roughly) corresponds to color represented by this stain vector.doublegetGreen()Get the green component of the (normalized) stain vector.getName()Returns the name of the stain vector.doublegetRed()Get the red component of the (normalized) stain vector.inthashCode()booleanReturns true if this vector represents the residual (orthogonal) stain, used whenever color deconvolution is required with two stains only.static StainVectorGet a default stain vector.voidtoString()void
-
Constructor Details
-
StainVector
public StainVector()Default constructor, required forExternalizableinterface.
-
-
Method Details
-
makeDefaultStainVector
Get a default stain vector.- Parameters:
stain-- Returns:
-
createStainVector
Create a stain vector.- Parameters:
name- the name of the stainr- the stain vector red componentg- the stain vector green componentb- 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
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
Get a String representation of the stain vector array, formatting according to the specified Locale.- Parameters:
locale-- Returns:
-
toString
-
equals
-
hashCode
public int hashCode() -
computeAngle
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
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-