public double[] RGBtoIHS(double r,double g,double b){
  double[] ret=new double[3];
  double i, h, s;
  double minRGB=b;
  i=r + g + b;
  if (g < minRGB) {
    minRGB=g;
  }
  if (r < minRGB) {
    minRGB=r;
  }
  if (i == 3) {
    h=0;
  }
 else   if (b == minRGB) {
    h=(g - b) / (i - 3 * b);
  }
 else   if (r == minRGB) {
    h=(b - r) / (i - 3 * r) + 1;
  }
 else {
    h=(r - g) / (i - 3 * g) + 2;
  }
  if (h <= 1) {
    s=(i - 3 * b) / i;
  }
 else   if (h <= 2) {
    s=(i - 3 * r) / i;
  }
 else {
    s=(i - 3 * g) / i;
  }
  ret[0]=i;
  ret[1]=h;
  ret[2]=s;
  return ret;
}

public double [ ] RGBtoIHS ( double r , double g , double b ) { double [ ] ret = new double [ 3 ] ; double i , h , s ; double minRGB = b ; i = r + g + b ; if ( g < minRGB ) { minRGB = g ; } if ( r < minRGB ) { minRGB = r ; } if ( i == 3 ) { h = 0 ; } else if ( b == minRGB ) { h = ( g - b ) / ( i - 3 * b ) ; } else if ( r == minRGB ) { h = ( b - r ) / ( i - 3 * r ) + 1 ; } else { h = ( r - g ) / ( i - 3 * g ) + 2 ; } if ( h <= 1 ) { s = ( i - 3 * b ) / i ; } else if ( h <= 2 ) { s = ( i - 3 * r ) / i ; } else { s = ( i - 3 * g ) / i ; } ret [ 0 ] = i ; ret [ 1 ] = h ; ret [ 2 ] = s ; return ret ; }
converts rgb colour values to ihs colour values
