public static void disparity ( GrayI disparity , int minValue , int maxValue , int invalidColor , Bitmap output , byte [ ] storage ) { shapeShape ( disparity , output ) ; if ( storage == null ) storage = declareStorage ( output , null ) ; int range = maxValue - minValue ; int indexDst = 0 ; for ( int y = 0 ; y < disparity . height ; y ++ ) { for ( int x = 0 ; x < disparity . width ; x ++ ) { int v = disparity . unsafe_get ( x , y ) ; int r , g , b ; if ( v > range ) { r = ( invalidColor >> 16 ) & 0xFF ; g = ( invalidColor >> 8 ) & 0xFF ; b = ( invalidColor ) & 0xFF ; } else { g = 0 ; if ( v == 0 ) { r = b = 0 ; } else { r = 255 * v / maxValue ; b = 255 * ( maxValue - v ) / maxValue ; } } storage [ indexDst ++ ] = ( byte ) r ; storage [ indexDst ++ ] = ( byte ) g ; storage [ indexDst ++ ] = ( byte ) b ; storage [ indexDst ++ ] = ( byte ) 0xFF ; } } output . copyPixelsFromBuffer ( ByteBuffer . wrap ( storage ) ) ; }
Colorizes a disparity image .