ApplyModalityLUT example for C++ Builder
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TestModalityLUT ( False );
}
L_INT TForm1::TestModalityLUT ( bool bLinear )
{
L_UINT16 LUT[0x10000];
L_INT nRet;
L_INT i;
L_INT nFirstStoredPixelValueMapped;
unsigned uEntryBits;
unsigned uNumberOfEntries;
LEADImage1->Load("e:\\image1.cmp", 0, 1, 1 );
if(bLinear)
{
nRet = LEADImage1->ApplyLinearModalityLUT(0.0, 0.5, 0);
}
else
{
// set a LUT which reduces the intensity of each pixel to half
for(i = 0; i <= 0xFFFF; i++)
LUT[i] = i / 2;
// fill the LUTDescriptor structure
nFirstStoredPixelValueMapped = 0;
uEntryBits = 16;
uNumberOfEntries = 0x10000;
// apply the LUT
nRet = LEADImage1->ApplyModalityLUT(LUT, uNumberOfEntries, nFirstStoredPixelValueMapped, uEntryBits, M_LUT_UPDATE_MIN_MAX);
}
return nRet;
}