I have a GeoTIFF file where the pixels are stored as unsigned 16 bit integers. I am using C# Gdal bindings to read the GeoTIFF file, using the Band.ReadRaster method, in order to produce an array of normalized values between 0 and 1.
I use ComputeRasterMinMax to compute the min and max value of all the data points in the band. For other GeoTiff files where pixels are stored as floats/doubles, it works out that the min and max are the absolute min and max elevation in meters. However, it is not clear to me if this is true when the pixels are stored as unsigned integers.
For instance, a sample file gives me 4000 as the min and 27000 as the max. If these are absolute elevations, then would I need to normalize each pixel via the method:
normalized pixel value = (pixel value - 4000) / 23000.
Is that correct, or should I normalize the pixels using ushort.MinValue and ushort.MaxValue, i.e.:
normalized pixel value = (pixel value - ushort.MinValue) / (ushort.MaxValue - ushort.MinValue)
which of course can be simplified given ushort.MinValue = 0.