Amit,
When you apply display-only window leveling on a 16-bit grayscale image (without modifying the pixel data), the only thing that changes is the display lookup table (LUT) of that image.
Our toolkit has the ability to save the LUT with the TIFF file, so that when you load the image again, you get the same LUT and therefore the same Window Leveling effect.
You can do this using our Main OCX 14 control as follows:
============================
LEAD1.Load "Grayscale16bit.tif", 0, 1, 1
LEAD1.WindowLevelBitmap = False
'Use all bits
LEAD1.LevelLowBit = 0
LEAD1.LevelHighBit = LEAD1.BitmapBits - 1
LEAD1.GetMinMaxBits
LEAD1.GetMinMaxVal
LEAD1.AutoRepaint = False
'Set LUT so the range is from pure blue to pure red
For i = LEAD1.MinVal To LEAD1.MaxVal
LEAD1.LevelLUT(i) = RGB(i Mod 256, 0, 256 - i Mod 256)
Next i
LEAD1.Save "Gray16LutModified.tif", FILE_TIF, 16, 0, SAVE_OVERWRITE
============================
This code will apply a blue-red gradient window level to the bitmap's lookup table (LUT) without modifying the grayscale pixel data. It will then save the image as 16-bit grayscale Tiff, which can then be loaded using LEADTOOLS with the LUT automatically applied upon loading.
Of course, you can set any LUT, not just this gradient in the sample.
This means the saved LUT is stored with the TIFF file which represents the 'current window level' values you applied to the image.