public static void RGBtoHSV(int R, int G, int B, float[] HSV) {
		// R,G,B in [0,255]
		float H = 0, S = 0, V = 0;
		float cMax = 255.0f;
		int cHi = Math.max(R, Math.max(G, B));
		int cLo = Math.min(R, Math.min(G, B));
		int cRng = cHi - cLo;

		// compute value V
		V = cHi / cMax;

		// compute saturation S
		if (cHi > 0)
			S = (float) cRng / cHi;

		// compute hue H
		if (cRng > 0) {
			float rr = (float) (cHi - R) / cRng;
			float gg = (float) (cHi - G) / cRng;
			float bb = (float) (cHi - B) / cRng;
			float hh;
			if (R == cHi)
				hh = bb - gg;
			else if (G == cHi)
				hh = rr - bb + 2.0f;
			else
				hh = gg - rr + 4.0f;
			if (hh < 0)
				hh = hh + 6;
			H = hh / 6;
		}

		if (HSV == null)
			HSV = new float[3];
		HSV[0] = H;
		HSV[1] = S;
		HSV[2] = V;
	}