public static float[] colorDeconvolveRGBArray(int[] buf, double[] stain1, double[] stain2, double[] stain3, int channel, float[] output) {
if (output == null || output.length != buf.length)
output = new float[buf.length];
if (stain3 == null)
stain3 = StainVector.cross3(stain1, stain2);
double[][] stainMat = new double[][]{stain1, stain2, stain3};
ColorDeconvMatrix3x3 mat3x3 = new ColorDeconvMatrix3x3(stainMat);
double[][] matInv = mat3x3.inverse();
double[] stain1Inv = matInv[0];
double[] stain2Inv = matInv[1];
double[] stain3Inv = matInv[2];
double[] od_lut = ColorDeconvolutionHelper.makeODLUT(255, 256);
for (int i = 0; i < buf.length; i++) {
int c = buf[i];
double r = od_lut[(c & 0xff0000) >> 16];
double g = od_lut[(c & 0xff00) >> 8];
double b = od_lut[c & 0xff];
output[i] = (float)(r * stain1Inv[channel] + g * stain2Inv[channel] + b * stain3Inv[channel]);
}
return output;
}