public int [ ] makeLut ( ) { int numKnots = x . length ; float [ ] nx = new float [ numKnots + 2 ] ; float [ ] ny = new float [ numKnots + 2 ] ; System . arraycopy ( x , 0 , nx , 1 , numKnots ) ; System . arraycopy ( y , 0 , ny , 1 , numKnots ) ; nx [ 0 ] = nx [ 1 ] ; ny [ 0 ] = ny [ 1 ] ; nx [ numKnots + 1 ] = nx [ numKnots ] ; ny [ numKnots + 1 ] = ny [ numKnots ] ; int [ ] table = new int [ 256 ] ; for ( int i = 0 ; i < 1024 ; i ++ ) { float f = i / 1024.0f ; int x = ( int ) ( 255 * Curve . Spline ( f , nx . length , nx ) + 0.5f ) ; int y = ( int ) ( 255 * Curve . Spline ( f , nx . length , ny ) + 0.5f ) ; x = x > 255 ? 255 : x ; x = x < 0 ? 0 : x ; y = y > 255 ? 255 : y ; y = y < 0 ? 0 : y ; table [ x ] = y ; } return table ; }
Create LUT .