public static float[] getTransformedMinAndMax(int[] buf, ColorTransformMethod method) { if (method == ColorTransformMethod.Original || method == ColorTransformMethod.Red || method == ColorTransformMethod.Green || method == ColorTransformMethod.Blue) return new float[]{0f, 255f}; if (method == ColorTransformMethod.White || method == ColorTransformMethod.Black) return new float[]{0f, 1f}; if (method == ColorTransformMethod.Hematoxylin_H_E || method == ColorTransformMethod.Hematoxylin_H_DAB || method == ColorTransformMethod.Eosin_H_E || method == ColorTransformMethod.DAB_H_DAB) return new float[]{0f, 2.f}; if (method == ColorTransformMethod.Hue || method == ColorTransformMethod.Saturation || method == ColorTransformMethod.Brightness) return new float[]{0f, 1f}; // if (method == IntColorMethod.Red_chromaticity || method == IntColorMethod.Green_chromaticity || method == IntColorMethod.Blue_chromaticity) float min = Float.POSITIVE_INFINITY; float max = Float.NEGATIVE_INFINITY; for (int v : buf) { float val = ColorTransformer.getPixelValue(v, method); if (val < min) min = val; if (val > max) max = val; } return new float[]{min, max}; }
@Override public float getValue(BufferedImage img, int x, int y) { int rgb = img.getRGB(x, y); return ColorTransformer.getPixelValue(rgb, method); }
@Override public float getValue(BufferedImage img, int x, int y) { ensureStainsUpdated(); if (stains == null) return 0f; int rgb = img.getRGB(x, y); if (method == null) return ColorDeconvolution.colorDeconvolveRGBPixel(rgb, stains, stainNumber-1); else if (method == ColorTransformMethod.Optical_density_sum) { int r = ColorTools.red(rgb); int g = ColorTools.green(rgb); int b = ColorTools.blue(rgb); return (float)(ColorDeconvolutionHelper.makeOD(r, stains.getMaxRed()) + ColorDeconvolutionHelper.makeOD(g, stains.getMaxGreen()) + ColorDeconvolutionHelper.makeOD(b, stains.getMaxBlue())); } else return ColorTransformer.getPixelValue(rgb, method); }