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.
- Author:
- Pete Bankhead
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum representing default stains. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionarrayAsString
(Locale locale) Get a String representation of the stain vector array, formatting according to the specified Locale.static double
computeAngle
(StainVector s1, StainVector s2) Calculate the angle between two stain vectors, in degrees.static StainVector
createStainVector
(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.double[]
getArray()
Get the stain vector as a 3 element array (red, green, blue).double
getBlue()
Get the blue component of the (normalized) stain vector.int
getColor()
Get a Color that (roughly) corresponds to color represented by this stain vector.double
getGreen()
Get the green component of the (normalized) stain vector.getName()
Returns the name of the stain vector.double
getRed()
Get the red component of the (normalized) stain vector.boolean
Returns true if this vector represents the residual (orthogonal) stain, used whenever color deconvolution is required with two stains only.static StainVector
Get a default stain vector.void
toString()
void
-
Constructor Details
-
StainVector
public StainVector()Default constructor, required forExternalizable
interface.
-
-
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
-
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:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-