Available in LEADTOOLS Medical Imaging toolkits. |
LevelLUT example for C++ 4.0 and later
This is also the example for MinVal property and MaxVal property.
The following example sets LevelLowBit and LevelHighBit to use all bits. It then gets the minimum and maximum bits and intensity values for the image, and 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.
long min;
long max;
long i;
m_Lead1.SetAutoRepaint(FALSE);
//use all bits
m_Lead1.SetLevelLowBit(0);
m_Lead1.SetLevelHighBit(m_Lead1.GetBitmapBits() - 1);
m_Lead1.GetMinMaxBits();
m_Lead1.GetMinMaxVal();
max = m_Lead1.GetMaxVal();
min = m_Lead1.GetMinVal();
//set LUT so that min range maps to RED and max range maps to BLUE
for( i=min; i<min+100; i++ )
m_Lead1.SetLevelLUT(i, RGB(255, 0, 0));
for( i=max-100; i<max; i++ )
m_Lead1.SetLevelLUT(i, RGB(0, 0, 255));
m_Lead1.SetAutoRepaint(TRUE);