public static void colorizeSign ( GrayF32 input , float maxAbsValue , Bitmap output , byte [ ] storage ) { shapeShape ( input , output ) ; if ( storage == null ) storage = declareStorage ( output , null ) ; if ( maxAbsValue < 0 ) maxAbsValue = ImageStatistics . maxAbs ( input ) ; int indexDst = 0 ; for ( int y = 0 ; y < input . height ; y ++ ) { int indexSrc = input . startIndex + y * input . stride ; for ( int x = 0 ; x < input . width ; x ++ ) { float value = input . data [ indexSrc ++ ] ; if ( value > 0 ) { storage [ indexDst ++ ] = ( byte ) ( 255f * value / maxAbsValue ) ; storage [ indexDst ++ ] = 0 ; storage [ indexDst ++ ] = 0 ; } else { storage [ indexDst ++ ] = 0 ; storage [ indexDst ++ ] = ( byte ) ( - 255f * value / maxAbsValue ) ; storage [ indexDst ++ ] = 0 ; } storage [ indexDst ++ ] = ( byte ) 0xFF ; } } output . copyPixelsFromBuffer ( ByteBuffer . wrap ( storage ) ) ; }
Renders positive and negative values as two different colors .