用 gdal_sieve 消除大团块?

Eliminate large clumps with gdal_sieve?

我有一个栅格数据集,并使用 gdal_sieve 消除由低于一定数量的像素组成的像素块。如何消除 像素块 一定数量的像素?

gdal_sieve.py 不支持删除超过阈值大小的对象。但是,似乎可以通过筛选低于阈值的对象然后计算输入图像和筛选图像之间的差异来实现所需的输出:

gdal_sieve.py -st <<threshold>> input.tif sieved.tif
gdal_calc.py -A input.tif -B sieved.tif --calc="A ^ B" --outfile=output.tif