Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mmse = oneImg.subtract(b).multiply(z.abs()).add(b.multiply(mmseIn))
# workflow
z99 = ee.Dictionary(img.reduceRegion(
reducer= ee.Reducer.percentile([99], None, 255, 0.001, 1e6),
geometry= img.geometry(),
scale= 10,
bestEffort= True
)).toImage()
overThresh = img.gte(z99)
K = overThresh.reduceNeighborhood(ee.Reducer.sum(), targetKernel, None, True)
retainPixel = K.gte(Tk)
xHat = geeutils.powerToDb(img.updateMask(retainPixel).unmask(mmse))
return ee.Image(xHat).rename(bandNames)
dir_mean).multiply(sigmaV)).divide(sigmaV.add(1.0))
b = varX.divide(dir_var)
# return multi-band image band from array
return dir_mean.add(b.multiply(img.subtract(dir_mean)))\
.arrayProject([0])\
.arrayFlatten([['sum']])\
.float()
bandNames = image.bandNames()
power= geeutils.dbToPower(image)
result = ee.ImageCollection(bandNames.map(
filter)).toBands().rename(bandNames)
return geeutils.powerToDb(ee.Image(result))
ci = variance.sqrt().divide(mean) # square root of inverse of enl
# If ci <= cu, the kernel lies in a "pure speckle" area -> return simple mean
cu = 1.0 / math.sqrt(enl)
# If cu < ci < cmax the kernel lies in the low textured speckle area -> return the filtered value
cmax = math.sqrt(2.0) * cu
alpha = ee.Image(1.0 + cu * cu).divide(ci.multiply(ci).subtract(cu * cu))
b = alpha.subtract(enl + 1.0)
d = mean.multiply(mean).multiply(b).multiply(b).add(
alpha.multiply(mean).multiply(nat_img).multiply(4.0 * enl))
f = b.multiply(mean).add(d.sqrt()).divide(alpha.multiply(2.0))
caster = ee.Dictionary.fromLists(bandNames, ee.List.repeat('float', 3))
img1 = geeutils.powerToDb(mean.updateMask(ci.lte(cu))
).rename(bandNames).cast(caster)
img2 = geeutils.powerToDb(f.updateMask(ci.gt(cu)).updateMask(
ci.lt(cmax))).rename(bandNames).cast(caster)
img3 = img.updateMask(ci.gte(cmax)).rename(bandNames).cast(caster)
# If ci > cmax do not filter at all (i.e. we don't do anything, other then masking)
result = ee.ImageCollection([img1, img2, img3])\
.reduce(ee.Reducer.firstNonNull()).rename(bandNames)\
.clip(img.geometry())
# Compose a 3 band image with the mean filtered "pure speckle", the "low textured" filtered and the unfiltered portions
return result