The easiest way for to do this - using IMAQ Vision Builder.
Just open your file in IVB, then select Grayscale -> Conversion -> 8
bit (Adjust dynamic). Then select Script -> Create LabVIEW VI. This
action produced VI named "IVB Adjust Dynamic.vi". In case if automatic
adjustment based on calculation min and max values of histogram not
very good for you, then you can set these values manually.
I had attached this vi to the posting.