public static final double makeODByLUT(double val, double[] OD_LUT) { return ColorDeconvolutionHelper.makeODByLUT((int)(val + .5), OD_LUT); }
public static final double makeODByLUT(float val, double[] OD_LUT) { return ColorDeconvolutionHelper.makeODByLUT((int)(val + .5f), OD_LUT); }
/** * Convert red channel of packed rgb pixel to optical density values, using a specified maximum value. * * @param rgb * @param maxValue * @param px optional array used for output * @return */ public static float[] getGreenOpticalDensities(int[] rgb, double maxValue, float[] px) { if (px == null) px = new float[rgb.length]; double[] od_lut = makeODLUT(maxValue, 256); for (int i = 0; i < px.length; i++) px[i] = (float)makeODByLUT(ColorTools.green(rgb[i]), od_lut); return px; }
/** * Convert red channel of packed rgb pixel to optical density values, using a specified maximum value. * * @param rgb * @param maxValue * @param px optional array used for output * @return */ public static float[] getBlueOpticalDensities(int[] rgb, double maxValue, float[] px) { if (px == null) px = new float[rgb.length]; double[] od_lut = makeODLUT(maxValue, 256); for (int i = 0; i < px.length; i++) px[i] = (float)makeODByLUT(ColorTools.blue(rgb[i]), od_lut); return px; }
/** * Convert red channel of packed rgb pixel to optical density values, using a specified maximum value. * * @param rgb * @param maxValue * @param px optional array used for output * @return */ public static float[] getRedOpticalDensities(int[] rgb, double maxValue, float[] px) { if (px == null) px = new float[rgb.length]; double[] od_lut = makeODLUT(maxValue, 256); for (int i = 0; i < px.length; i++) px[i] = (float)makeODByLUT(ColorTools.red(rgb[i]), od_lut); return px; }
/** * For originally-8-bit images, optical densities can usually be computed faster by preallocating a LUT with the 0-255 required values. * Otherwise, logs need to be calculated for every pixel (which can be relatively slow). * * @param px * @param maxValue * @param use8BitLUT */ public static void convertPixelsToOpticalDensities(float[] px, double maxValue, boolean use8BitLUT) { if (use8BitLUT) { double[] od_lut = makeODLUT(maxValue, 256); for (int i = 0; i < px.length; i++) px[i] = (float)makeODByLUT(px[i], od_lut); } else { for (int i = 0; i < px.length; i++) px[i] = (float)makeOD(px[i], maxValue); } }