ApplyModalityLUT example for Delphi
procedure TForm1.Button1Click(Sender: TObject);
begin
TestModalityLUT(False);
end;
Function TForm1.TestModalityLUT ( bLinear: Boolean ): L_INT;
var
LUT: Array[0..$FFFF] of L_UINT16;
nRet: L_INT;
i: L_INT;
nFirstStoredPixelValueMapped: L_INT;
uEntryBits: L_UINT;
uNumberOfEntries: L_UINT;
begin
LEADImage1.Load('e:\image1.cmp', 0, 1, 1 );
if (bLinear = True) then
begin
nRet:= LEADImage1.ApplyLinearModalityLUT(0.0, 0.5, 0);
end
else
begin
{ set a LUT which reduces the intensity of each pixel to half }
for i:= 0 to $FFFF do
begin
LUT[i]:= Trunc(i / 2);
end;
{ fill the LUTDescriptor structure }
nFirstStoredPixelValueMapped:= 0;
uEntryBits:= 16;
uNumberOfEntries:= $10000;
{ apply the LUT }
nRet:= LEADImage1.ApplyModalityLUT( @LUT, uNumberOfEntries, nFirstStoredPixelValueMapped, uEntryBits, M_LUT_UPDATE_MIN_MAX );
end;
Result:= nRet;
end;