/** Returns the color components in the specified color space from * RGB values. */ public static float[] fromRGB(ColorSpace colorSpace, int r, int g, int b) { return colorSpace.fromRGB(new float[]{r / 255f, g / 255f, b / 255f}); }
float[] temp = dstColorSpace.fromRGB(rgbResult); System.arraycopy(temp, 0, dstComponents, 0, Math.min(dstComponents.length, temp.length));
float[] xyz = CIEXYZ.fromRGB(rgbvalue); return fromCIEXYZ(xyz);
/** * @param hsv * @return * @see java.awt.color.ColorSpace#toCIEXYZ(float[]) */ @Override public float[] toCIEXYZ(float[] hsv) { float[] rgb = this.toRGB(hsv); ColorSpace CIEXYZcs = ColorSpace.getInstance(CS_CIEXYZ); return CIEXYZcs.fromRGB(rgb); }
@Override public float[] fromRGB(float[] rgbvalue) { float[] ciexyz = sRGB.fromRGB(rgbvalue); return fromCIEXYZ(ciexyz); }
public float[] toCIEXYZ(float[] colorvalue) { if (colorvalue[0]==1) { return prev1; } else if (colorvalue[0]==0) { return prev0; } else { // System.out.println("MaskColorSpace converting: "+colorvalue[0]); return cie.fromRGB(toRGB(colorvalue)); } }
public float[] toCIEXYZ(float[] colorvalue) { if (colorvalue[0]==1) { return prev1; } else if (colorvalue[0]==0) { return prev0; } else { // System.out.println("MaskColorSpace converting: "+colorvalue[0]); return cie.fromRGB(toRGB(colorvalue)); } }
@Override public float[] fromRGB(float[] rgbvalue) { float[] ciexyz = sRGB.fromRGB(rgbvalue); return fromCIEXYZ(ciexyz); }
public float[] toCIEXYZ(float[] colorvalue) { if (colorvalue[0]==1) { return prev1; } else if (colorvalue[0]==0) { return prev0; } else { // System.out.println("MaskColorSpace converting: "+colorvalue[0]); return cie.fromRGB(toRGB(colorvalue)); } }
@Override public float[] fromRGB(float[] rgbvalue) { float[] xyz = CIEXYZ.fromRGB(rgbvalue); return fromCIEXYZ(xyz); }
@Override public float[] fromRGB(float[] floats) { return fromCIEXYZ(CIEXYZ.fromRGB(floats)); }
@Override public float getDistance(int color1, int color2) { if (color1 == color2) { return 0; } float[] rgb1 = ColorModelRGBA.getRGB(color1); float[] rgb2 = ColorModelRGBA.getRGB(color2); float[] cieLab1 = colorSpaceLAB.fromRGB(rgb1); float[] cieLab2 = colorSpaceLAB.fromRGB(rgb2); return getDistance(cieLab1, cieLab2); }
private static double getColorError(Color color1, Color color2) { float[] rgb1 = color1.getRGBColorComponents(null); float[] rgb2 = color2.getRGBColorComponents(null); ColorSpace labSpace = new CIELab(); float[] lab1 = labSpace.fromRGB(rgb1); float[] lab2 = labSpace.fromRGB(rgb2); double deltaL = lab1[0] - lab2[0]; double deltaA = lab1[1] - lab2[1]; double deltaB = lab1[2] - lab2[2]; double c1 = Math.sqrt(lab1[1]*lab1[1] + lab1[2]*lab1[2]); double c2 = Math.sqrt(lab2[1]*lab2[1] + lab2[2]*lab2[2]); double deltaC = c1 - c2; double deltaH = deltaA*deltaA + deltaB*deltaB - deltaC*deltaC; deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH); double sc = 1.0 + k1*c1; double sh = 1.0 + k2*c1; double l = deltaL/(kl*sl); double c = deltaC/(kc*sc); double h = deltaH/(kh*sh); double i = l*l + c*c + h*h; return i < 0 ? 0 : Math.sqrt(i); }
public static PrintColor createPrintColor(Color color) { if (color == null) { return null; } if (color instanceof PrintColor) { return (PrintColor) color; } // convert a awt.Color to some reasonable PrintColor. // pure white converts to black, and vice versa. float[] gray = ColorSpace.getInstance( ColorSpace.CS_GRAY).fromRGB( color.getRGBComponents(null)); if (gray[0] == 0.0f) { gray[0] = 1.0f; } else if (gray[0] == 1.0f) { gray[0] = 0.0f; } return new PrintColor(color, gray[0], !color.equals(Color.black)); }
public static PrintColor createPrintColor(Color color) { if (color == null) { return null; } if (color instanceof PrintColor) { return (PrintColor) color; } // convert a awt.Color to some reasonable PrintColor. // pure white converts to black, and vice versa. float[] gray = ColorSpace.getInstance( ColorSpace.CS_GRAY).fromRGB( color.getRGBComponents(null)); if (gray[0] == 0.0f) { gray[0] = 1.0f; } else if (gray[0] == 1.0f) { gray[0] = 0.0f; } return new PrintColor(color, gray[0], !color.equals(Color.black)); }
rgbValue[1] = (rgb[i] >> 8) & 0xFF; // GREEN rgbValue[2] = (rgb[i] >> 0) & 0xFF; // BLUE float[] luv = space.fromRGB(rgbValue); double[] arr = new double[luv.length]; for (int x = 0; x < luv.length; x++) {
@Override public float[] fromRGB(float[] rgbvalue) { ColorSpace cieXYZSpace = ColorSpaceXYZ.getInstance(); float[] cieXYZ = cieXYZSpace.fromRGB(rgbvalue); double x = cieXYZ[0]; double y = cieXYZ[1]; double z = cieXYZ[2]; x = x / REF_X; y = y / REF_Y; z = z / REF_Z; x = transform(x); y = transform(y); z = transform(z); Double l = (116.0 * y) - 16.0; Double a = 500.0 * (x - y); Double b = 200.0 * (y - z); float[] cieLAB = new float[cieXYZ.length]; cieLAB[0] = l.floatValue(); cieLAB[1] = a.floatValue(); cieLAB[2] = b.floatValue(); for (int i = 3; i < cieXYZ.length; i++) { cieXYZ[i] = cieXYZ[i]; } return cieLAB; }
float[] fromRGB = instance.fromRGB(rgb); return fromRGB;
float[] fromRGB = instance.fromRGB(rgb); return fromRGB;
float[] fromRGB = instance.fromRGB(rgb); return fromRGB;