matchHistogram#
- geetools.ee_image.ImageAccessor.matchHistogram(target, bands, geometry=None, maxBuckets=256, scale=30, maxPixels=65536 * 4 - 1, bestEffort=True)#
Adjust the image’s histogram to match a target image.
This method performs histogram matching on individual bands independently. While this adjusts the value distribution of each band to match the target, it does not account for the relationships between the bands. As a result, you might observe changes in the hue of the image after applying this function, as the relative intensities of the different color bands are altered independently.
For histogram matching that preserves the hue of the image, consider using the matchHistogramHSV method available in geetools.
From: https://medium.com/google-earth/histogram-matching-c7153c85066d
- Parameters:
target (ee.Image) – Image to match.
bands (dict[str, str]) – A dictionary of band names to match, with source bands as keys and target bands as values.
geometry (ee.Geometry | None) – The region to match histograms in that overlaps both images. If none is provided, the geometry of the source image will be used.
maxBuckets (int) – The maximum number of buckets to use when building histograms. Will be rounded to the nearest power of 2.
scale (int) – the spatial resolution to compute the histograms.
maxPixels (int) – The maximum number of pixels to compute the histogram.
bestEffort (bool) – If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed.
- Returns:
The adjusted image containing the matched source bands.
- Return type:
Examples
import ee import geetools ee.Initialize() source = ee.Image("LANDSAT/LC08/C01/T1_TOA/LC08_047027_20160819") target = ee.Image("LANDSAT/LE07/C01/T1_TOA/LE07_046027_20150701") bands = { "B4": "B3", "B3": "B2", "B2": "B1" } matched = source.geetools.matchHistogram(target, bands)