Available in LEADTOOLS Medical Imaging toolkits. |
WindowLevelFillLUT example for C++ 4.0 and later
long nHigh;
long nLow;
long fSigned;
m_Lead1.Grayscale(16);
m_Lead1.GetMinMaxBits();
m_Lead1.GetMinMaxVal();
m_Lead1.SetLevelLowBit(0);
m_Lead1.SetLevelHighBit(m_Lead1.GetBitmapBits() - 1);
nLow = m_Lead1.GetMinBit();
nHigh = 1<<(m_Lead1.GetMaxBit() - m_Lead1.GetMinBit() + 1);
//allocate the LUT
m_Lead1.SetLevelLUT(nHigh - 1, 0);
//set the FILLLUT_SIGNED flag for signed images
fSigned = FILLLUT_UNSIGNED;
if (m_Lead1.GetIsSigned())
{
fSigned = FILLLUT_SIGNED;
}
//fill the entire LUT with gradient from RED to BLUE
m_Lead1.WindowLevelFillLUT( RGB(255, 0, 0),
RGB(0, 0, 255),
nLow, nHigh,
m_Lead1.GetMinBit(),
m_Lead1.GetMaxBit(),
m_Lead1.GetMinVal(),
m_Lead1.GetMaxVal(),
0,
FILLLUT_INSIDE | FILLLUT_LINEAR | fSigned);
//now use it
m_Lead1.WindowLevel();