I'm trying to compute ONE histogram for an entire ImageCollection in Google Earth Engine (example code here: https://code.earthengine.google.com/b10f5136a79a6309e381ae11aa9b7431)
What I'm doing now to achieve the result I want, is to calculate the histograms for each individual image histogram1
and add them up - such as here in Python API:
for j in range(0,norm_size):
print('Procressing Image #', j+1, ' out of ', norm_size)
image = ee.Image(norm_list.get(j));
histogram1 = image.reduceRegion(
reducer = ee.Reducer.fixedHistogram(0,1,255),
geometry = s2_norm.geometry(),
maxPixels = 10e9
).get(band)
try:
dic = histogram1.getInfo()
if j==0:
for l in range(0,255):
bins[0,l] = dic[l][0]
counts[0,l] = dic[l][1]
else:
for l in range(0,255):
counts[0,l] = counts[0,l] + dic[l][1]
except (IndexError):
print(j,'Empty')
pass
This works fine, but it takes AGES, because of the getInfo()
.
Is there a smart GEE way, to get one histogram for the entire Imagecollection, that is not an image but a simple list, such as in the example code?