LevelLUT example for Delphi

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.

var
   min: Longint;
   max: Longint;
   i: Longint;
begin
   LEADRasterView1.AutoRepaint := False;
   //use all bits
   LEADRasterView1.Raster.LevelLowBit := 0;
   LEADRasterView1.Raster.LevelHighBit:= LEADRasterView1.Raster.BitmapBits - 1;

   LEADRasterView1.Raster.GetMinMaxBits ();
   LEADRasterView1.Raster.GetMinMaxVal ();
   max := LEADRasterView1.Raster.MaxVal;
   min := LEADRasterView1.Raster.MinVal;

   //set LUT so that min range maps to RED and max range maps to BLUE
   for i := min to min + 100 do
      LEADRasterView1.Raster.LevelLUT [i] := RGB(255, 0, 0);
   for i := max - 100 to max do
      LEADRasterView1.Raster.LevelLUT[i] := RGB(0, 0, 255);
   LEADRasterView1.AutoRepaint := True;
end;