public static void positive ( TupleDesc_F64 input , TupleDesc_U8 output ) { double max = 0 ; for ( int i = 0 ; i < input . size ( ) ; i ++ ) { double v = input . value [ i ] ; if ( v > max ) max = v ; } if ( max == 0 ) max = 1.0 ; for ( int i = 0 ; i < input . size ( ) ; i ++ ) { output . value [ i ] = ( byte ) ( 255.0 * input . value [ i ] / max ) ; } }
Converts a floating point description with all positive values into the 8 - bit integer descriptor by dividing each element in the input by the element maximum value and multiplying by 255 .