LevelLUT example for Visual J++

This is also the example for MinVal property and MaxVal property.

The following example sets LevelLowBit and LevelHighBit to use all bits, gets the minimum and maximum bits and intensity values for the image, and then sets the LUT so that pixels with values in the minimum range are mapped to the color RED, while pixels with values in the maximum range are mapped to BLUE.

LEAD1.setAutoRepaint( false );

// use all bits
LEAD1.setLevelLowBit( (short) 0 );
LEAD1.setLevelHighBit( (short) ( LEAD1.getBitmapBits() - 1 ) );

LEAD1.GetMinMaxBits();
LEAD1.GetMinMaxVal();
int nMax = LEAD1.getMaxVal();
int nMin = LEAD1.getMinVal();

// set LUT so that min range maps to RED and max range maps to BLUE
for( int i = nMin ; i <= ( nMin + 100 ) ; i++ )
   LEAD1.setLevelLUT( i, new Color( 255, 0, 0 ) );
for( int i = nMax - 100 ; i <= nMax ; i++ )
   LEAD1.setLevelLUT( i, new Color( 0, 0, 255 ) );
LEAD1.setAutoRepaint( true );