Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@decorators.carryMetadata
def applyBmax(img):
def constuctGrid(i):
def contructXGrid(j):
j = ee.Number(j)
box = ee.Feature(ee.Geometry.Rectangle(j,i,j.add(gridSize),i.add(gridSize)))
out = ee.Algorithms.If(geom.contains(box.geometry(),maxError=1),box,None)
return ee.Feature(out)
i = ee.Number(i)
out = ee.List.sequence(west,east.subtract(gridSize),gridSize).map(contructXGrid)
return out
def calcBmax(feature):
segment = img#.clip(feature)
initial = segment.lt(initialThreshold)
@decorators.carryMetadata
def powerToDb(img):
return ee.Image(10).multiply(img.log10())
@decorators.carryMetadata
def applyFilter(image):
def filter(b):
img = power.select([b])
# img must be in natural units, i.e. not in dB!
# Set up 3x3 kernels
weights3 = ee.List.repeat(ee.List.repeat(1, 3), 3)
kernel3 = ee.Kernel.fixed(3, 3, weights3, 1, 1, False)
mean3 = img.reduceNeighborhood(ee.Reducer.mean(), kernel3)
variance3 = img.reduceNeighborhood(ee.Reducer.variance(), kernel3)
# Use a sample of the 3x3 windows inside a 7x7 windows to determine gradients and directions
sample_weights = ee.List([[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [
0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]])
@decorators.carryMetadata
def dbToPower(img):
return ee.Image(10).pow(img.divide(10))