How to use the hydrafloods.geeutils.dbToPower function in hydrafloods

To help you get started, we’ve selected a few hydrafloods examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Servir-Mekong / hydra-floods / hydrafloods / filtering.py View on Github external
def applyFilter(img):
        img = geeutils.dbToPower(img)

        # MMSE estimator
        mmseMask = img.gte(a1).Or(img.lte(a2))
        mmseIn = img.updateMask(mmseMask)
        oneImg = ee.Image(1)
        z = mmseIn.reduceNeighborhood(ee.Reducer.mean(), kernel, None, True)
        varz = mmseIn.reduceNeighborhood(ee.Reducer.variance(), kernel)
        varx = (varz.subtract(z.abs().pow(2).multiply(eta))).divide(oneImg.add(eta))
        b = varx.divide(varz)
        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,
github Servir-Mekong / hydra-floods / hydrafloods / filtering.py View on Github external
def applyFilter(img):
        # Convert image from dB to natural values
        nat_img = geeutils.dbToPower(img)

        # Get mean and variance
        mean = nat_img.reduceNeighborhood(ee.Reducer.mean(), kernel)
        variance = nat_img.reduceNeighborhood(ee.Reducer.variance(), kernel)

        # "Pure speckle" threshold
        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)
github Servir-Mekong / hydra-floods / hydrafloods / filtering.py View on Github external
dir_var = dir_var.reduce(ee.Reducer.sum())

            # A finally generate the filtered value
            varX = dir_var.subtract(dir_mean.multiply(
                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))