Hmm, good catch.  Looking at the stats for the red band:

Band 1 Block=128x128 Type=UInt16, ColorInterp=Gray
  Min=130.000 Max=36265.000
  Minimum=130.000, Maximum=36265.000, Mean=10415.962, StdDev=3502.933
  NoData Value=0
  Metadata:
    STATISTICS_MAXIMUM=36265
    STATISTICS_MEAN=10415.961859513
    STATISTICS_MINIMUM=130
    STATISTICS_STDDEV=3502.9325925887
    STATISTICS_VALID_PERCENT=49

So, is there no way to actually do this via command line, or am I going to have 
to write a python lib to actually read through these and determine what they 
should be scaled to?

From: Daniel Evans <daniel.fred.ev...@gmail.com>
Sent: Monday, April 22, 2024 9:29 AM
To: Raley, Nathan <nra...@gaig.com>
Cc: 'gdal-dev@lists.osgeo.org' (gdal-dev@lists.osgeo.org) 
<gdal-dev@lists.osgeo.org>
Subject: [External] Re: [gdal-dev] Question on building multi band composite 
and going back to RGB GeoTiff

Hi Nathan, My initial suspicion might just be that the scaling the data 
provider did to go from the raw data to a human-eye-friendly RGB composite 
isn't the conversion you're assuming. I know that with the data I regularly 
work with,

Hi Nathan,

My initial suspicion might just be that the scaling the data provider did to go 
from the raw data to a human-eye-friendly RGB composite isn't the conversion 
you're assuming.

I know that with the data I regularly work with, it may be provided as Uint16, 
but the data range doesn't extend all the way to 65535.

If you compare the values in the separate R and G images to the RGB composite, 
do they appear to match the conversion you're assuming, or is there a different 
scaling (and possibly offset)?

Cheers,
Daniel

On Mon, 22 Apr 2024, 15:20 Raley, Nathan via gdal-dev, 
<gdal-dev@lists.osgeo.org<mailto:gdal-dev@lists.osgeo.org>> wrote:
I currently have a RGB geotiff composite image that has a Byte datatype.  I 
also have individual band images for R, G, Redge, and NIR that are UInt16 
datatypes.  Since I’m missing the Blue band from the individual bands, I was 
attempting to extract the blue band from the RGB composite image, scale it up 
to the UInt16 datatype, and build a composite VRT with R, G, B, NIR, RE bands 
included in it.  I was then attempting to extract the RGB bands from the 
multispec VRT in order to see if the process was working as intended, but I’m 
getting an extremely blue image.

Can anyone shed some light as to what I may be doing wrong here?

I started by building a VRT for each band:
gdal_translate source_RGB.tif b.vrt -ot UInt16 -of VRT -b 3 -scale 0 255 0 65535
gdalbuildvrt -b 1 r.vrt source_R.tif
gdalbuildvrt -b 1 g.vrt source_G.tif
gdalbuildvrt -b 1 nir.vrt source_NIR.tif
gdalbuildvrt -b 1 re.vrt source_RE.tif

I then merged the VRTs:
gdalbuildvrt -separate multispec.vrt r.vrt g.vrt b.vrt nir.vrt re.vrt

I now have a multispec.vrt with the R, G, B, NIR, and RE bands, all with a 
UInt16 datatype.

Now, I attempted to rebuild a RGB GeoTiff from the composite VRT with something 
like:
gdal_translate -ot Byte -of GTiff -b 1 -b 2 -b 3 -scale 0 65535 0 255 -co 
PHOTOMETRIC=RGB multispec.vrt multispec.tif

Viewing the result in QGIS appears overly blue.  What am I doing wrong here?

Thanks,
Nathan

________________________________
This email transmission, including any attachments, is intended solely for the 
addressee named above, and may contain confidential or privileged information. 
If you are not the intended recipient, be aware that any disclosure, copying, 
distribution or use of the contents of this e-mail is prohibited. If you have 
received this e-mail in error, please notify the sender immediately by reply 
email and destroy the message and its attachments.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org<mailto:gdal-dev@lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/gdal-dev<https://urldefense.com/v3/__https:/lists.osgeo.org/mailman/listinfo/gdal-dev__;!!CsmrWXz9mOkSc4Hdn1fjj00!wHjHtqIprjw9nQ3elKNFMUWmEwR3sKx-zrxpsNEk-kBIhomauYshqPep8-beAmn7Ma8NlmL95Mqf9c8fol37c2o$>

This email transmission, including any attachments, is intended solely for the 
addressee named above, and may contain confidential or privileged information. 
If you are not the intended recipient, be aware that any disclosure, copying, 
distribution or use of the contents of this e-mail is prohibited. If you have 
received this e-mail in error, please notify the sender immediately by reply 
email and destroy the message and its attachments.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to