code: public static void rgbToHsv( double r , double g , double b , double []hsv ) {
  		// Maximum value
  		double max = r > g ? ( r > b ? r : b) : ( g > b ? g : b );
  		// Minimum value
  		double min = r < g ? ( r < b ? r : b) : ( g < b ? g : b );
  		double delta = max - min;
  
  		hsv[2] = max;
  
  		if( max != 0 )
  			hsv[1] = delta / max;
  		else {
  			hsv[0] = Double.NaN;
  			hsv[1] = 0;
  			return;
  		}
  
  		double h;
  		if( r == max )
  			h = ( g - b ) / delta;
  		else if( g == max )
  			h = 2 + ( b - r ) / delta;
  		else
  			h = 4 + ( r - g ) / delta;
  
  		h *= d60_F64;
  		if( h < 0 )
  			h += PI2_F64;
  
  		hsv[0] = h;
  	}
docs: Convert RGB color into HSV color
  
  @param r red
  @param g green
  @param b blue
  @param hsv (Output) HSV value.