Package qupath.lib.analysis.algorithms
Class EstimateStainVectors
java.lang.Object
qupath.lib.analysis.algorithms.EstimateStainVectors
Code for estimating stain vectors automatically from an image, or to launch an editor for visually/interactively modifying stain vectors.
Aspects of the automated method take inspiration from Macenko's 2009 paper 'A METHOD FOR NORMALIZING HISTOLOGY SLIDES FOR QUANTITATIVE ANALYSIS' although it also differs through its use of preprocessing and parameters, as well as its selection of an actual pixel value rather than projecting on the identified plane.
- Author:
- Pete Bankhead
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ColorDeconvolutionStains
estimateStains
(int[] rgbPacked, float[] redOD, float[] greenOD, float[] blueOD, ColorDeconvolutionStains stainsOriginal, double minStain, double maxStain, double ignorePercentage, boolean checkColors) Check colors only currently applies to H&E.static ColorDeconvolutionStains
estimateStains
(BufferedImage img, ColorDeconvolutionStains stainsOriginal, boolean checkColors) Estimate two stains from a BufferedImage, with default parameter settings.static ColorDeconvolutionStains
estimateStains
(BufferedImage img, ColorDeconvolutionStains stainsOriginal, double minStain, double maxStain, double ignorePercentage, boolean checkColors) Estimate two stains from a BufferedImage.static int[]
getModeRGB
(int[] rgb) Get the mode from an array of (packed) RGB pixel values.static BufferedImage
smoothImage
(BufferedImage img) Smooth out compression artefacts by running 3x3 filter twice (roughly approximates a small Gaussian filter).static int[]
subsample
(int[] arr, int maxEntries) Subsample an array so that it contains no more than maxEntries.
-
Constructor Details
-
EstimateStainVectors
public EstimateStainVectors()
-
-
Method Details
-
estimateStains
public static ColorDeconvolutionStains estimateStains(BufferedImage img, ColorDeconvolutionStains stainsOriginal, boolean checkColors) Estimate two stains from a BufferedImage, with default parameter settings.- Parameters:
img
- original RGB imagestainsOriginal
- original stains, including the background (white) values for red, green and blue and stain namescheckColors
- if true, avoid colors far from H&E- Returns:
-
estimateStains
public static ColorDeconvolutionStains estimateStains(BufferedImage img, ColorDeconvolutionStains stainsOriginal, double minStain, double maxStain, double ignorePercentage, boolean checkColors) Estimate two stains from a BufferedImage.- Parameters:
img
- original RGB imagestainsOriginal
- original stains, including the background (white) values for red, green and blue and stain namesminStain
- minimum optical density to usemaxStain
- maximum optical density to useignorePercentage
- percentage of extrema pixels to ignorecheckColors
- if true, avoid colors far from H&E- Returns:
-
estimateStains
public static ColorDeconvolutionStains estimateStains(int[] rgbPacked, float[] redOD, float[] greenOD, float[] blueOD, ColorDeconvolutionStains stainsOriginal, double minStain, double maxStain, double ignorePercentage, boolean checkColors) Check colors only currently applies to H&E.- Parameters:
rgbPacked
-redOD
-greenOD
-blueOD
-stainsOriginal
-minStain
-maxStain
-ignorePercentage
-checkColors
-- Returns:
-
subsample
public static int[] subsample(int[] arr, int maxEntries) Subsample an array so that it contains no more than maxEntries. No guarantee is made that the resulting array will contain *exactly* maxEntries, but rather equal spacing between entries will be used.If arr.length <= maxEntries, the array is returned unchanged.
- Parameters:
arr
-maxEntries
-- Returns:
-
smoothImage
Smooth out compression artefacts by running 3x3 filter twice (roughly approximates a small Gaussian filter).- Parameters:
img
-- Returns:
-
getModeRGB
public static int[] getModeRGB(int[] rgb) Get the mode from an array of (packed) RGB pixel values.- Parameters:
rgb
-- Returns:
- an array with 3 entries giving the Red, Green & Blue values (in order) corresponding to the mode of each channel from the packed RGB pixel array.
-