/** * Deconvolve RGB array with one set of stain vectors, and reconvolve with another. * This supports in-place operation, i.e. buf and bufOutput can be the same array. * Otherwise, if bufOutput == null, a new output array will be created. * * @param buf * @param stainsInput * @param stainsOutput * @param discardResidual * @param bufOutput * @return */ public static int[] colorDeconvolveReconvolveRGBArray(int[] buf, ColorDeconvolutionStains stainsInput, ColorDeconvolutionStains stainsOutput, boolean discardResidual, int[] bufOutput) { return colorDeconvolveReconvolveRGBArray(buf, stainsInput, stainsOutput, discardResidual, bufOutput, 1f, 0f); }
@Override public synchronized float[] getValues(BufferedImage img, int x, int y, int w, int h, float[] array) { ensureStainsUpdated(); if (stains == null) { if (array == null) return new float[w * h]; return array; } int[] buffer = RGBDirectChannelInfo.getRGBIntBuffer(img); if (buffer == null) buffer = img.getRGB(x, y, w, h, null, 0, w); if (method == null) return ColorDeconvolution.colorDeconvolveRGBArray(buffer, stains, stainNumber-1, array); else return ColorTransformer.getTransformedPixels(buffer, method, array, stains); }
@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); }
r = pow10Approx(stain1 * d00 + stain2 * d10) * maxRed; g = pow10Approx(stain1 * d01 + stain2 * d11) * maxGreen; b = pow10Approx(stain1 * d02 + stain2 * d12) * maxBlue; } else { r = pow10Approx(stain1 * d00 + stain2 * d10 + stain3 * d20) * maxRed; g = pow10Approx(stain1 * d01 + stain2 * d11 + stain3 * d21) * maxGreen; b = pow10Approx(stain1 * d02 + stain2 * d12 + stain3 * d22) * maxBlue;
@Override public int getRGB(BufferedImage img, int x, int y, boolean useColorLUT) { int[] arr = new int[]{img.getRGB(x, y)}; return ColorDeconvolution.colorDeconvolveReconvolveRGBArray(arr, imageDisplay.getImageData().getColorDeconvolutionStains(), stainsTarget, discardResidual, arr)[0]; }
@Override public int[] getRGB(BufferedImage img, int[] rgb, boolean useColorLUT) { int[] buffer = RGBDirectChannelInfo.getRGBIntBuffer(img); if (buffer == null) buffer = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth()); return ColorDeconvolution.colorDeconvolveReconvolveRGBArray(buffer, imageDisplay.getImageData().getColorDeconvolutionStains(), stainsTarget, discardResidual, rgb, getScaleToByte(), -getOffset()); }