namespace mimas {template <typename T>double rgba<T>::getHue(void) const{/**returns a HUE value for the pixel, in the range 0-360.*hue is 'supposed' to represent the colour of a pixel, once brightness levels*and so on have been removed. Returns -1 for an undefined hue.*/T min,max,delta;double h;// calculate the huemin = r;if (g<r && g<b) min=g;if (b<r && b<g) min=b;max = r;if (g>r && g>b) max=g;if (b>r && b>g) max=b;if (min==max) //undefined hue{ return (T) -1; }/* algo 2... */delta = max - min;if ( r == max )h = ((double)( g - b )) / (double) delta;// between yellow & magentaelse if( g == max )h = 2.0 + ((double)( b - r )) / (double) delta;// between cyan & yellowelseh = 4.0 + ((double)( r - g )) / (double) delta;// between magenta & cyanh *= 60; // degreesif( h < 0 )h += 360;return h;}template <typename T>double rgba<T>::getSaturation(void) const{/**returns the saturation value for the pixel.*saturation lies between 0-1*/T min,max,delta;double s;min = r;if (g<r && g<b) min=g;if (b<r && b<g) min=b;max = r;if (g>r && g>b) max=g;if (b>r && b>g) max=b;s = ((double)(max - min))/(double)max;return s;}}