public static void histogram ( double [ ] colors , int length , Histogram_F64 histogram ) { if ( length % histogram . getDimensions ( ) != 0 ) throw new IllegalArgumentException ( "Length does not match dimensions" ) ; int coordinate [ ] = new int [ histogram . getDimensions ( ) ] ; histogram . fill ( 0 ) ; for ( int i = 0 ; i < length ; ) { for ( int j = 0 ; j < coordinate . length ; j ++ , i ++ ) { coordinate [ j ] = histogram . getDimensionIndex ( j , colors [ i ] ) ; } int index = histogram . getIndex ( coordinate ) ; histogram . value [ index ] += 1.0 ; } }
Computes a coupled histogram from a list of colors . If the input is for integer values then add one to the maximum value . For example if the range of values is 0 to 255 then make it 0 to 256 .