公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Kernel.add
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在对齐两个核的中心后,按元素添加这两个核。
用法 | 返回 |
---|
Kernel.add(kernel2, normalize) | 内核 |
参数 | 类型 | 详细信息 |
---|
此:kernel1 | 内核 | 第一个内核。 |
kernel2 | 内核 | 第二个内核。 |
normalize | 布尔值,默认值:false | 对内核进行归一化处理。 |
示例
代码编辑器 (JavaScript)
// Two kernels, they do not need to have the same dimensions.
var kernelA = ee.Kernel.chebyshev({radius: 3});
var kernelB = ee.Kernel.square({radius: 1, normalize: false, magnitude: 100});
print(kernelA, kernelB);
/**
* Two kernel weights matrices
*
* [3, 3, 3, 3, 3, 3, 3]
* [3, 2, 2, 2, 2, 2, 3]
* [3, 2, 1, 1, 1, 2, 3] [100, 100, 100]
* A [3, 2, 1, 0, 1, 2, 3] B [100, 100, 100]
* [3, 2, 1, 1, 1, 2, 3] [100, 100, 100]
* [3, 2, 2, 2, 2, 2, 3]
* [3, 3, 3, 3, 3, 3, 3]
*/
print('Pointwise addition of two kernels', kernelA.add(kernelB));
/**
* [3, 3, 3, 3, 3, 3, 3]
* [3, 2, 2, 2, 2, 2, 3]
* [3, 2, 101, 101, 101, 2, 3]
* [3, 2, 101, 100, 101, 2, 3]
* [3, 2, 101, 101, 101, 2, 3]
* [3, 2, 2, 2, 2, 2, 3]
* [3, 3, 3, 3, 3, 3, 3]
*/
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
from pprint import pprint
# Two kernels, they do not need to have the same dimensions.
kernel_a = ee.Kernel.chebyshev(**{'radius': ee.Number(3)})
kernel_b = ee.Kernel.square(**{
'radius': 1,
'normalize': False,
'magnitude': 100
})
pprint(kernel_a.getInfo())
pprint(kernel_b.getInfo())
# Two kernel weights matrices
# [3, 3, 3, 3, 3, 3, 3]
# [3, 2, 2, 2, 2, 2, 3]
# [3, 2, 1, 1, 1, 2, 3] [100, 100, 100]
# A [3, 2, 1, 0, 1, 2, 3] B [100, 100, 100]
# [3, 2, 1, 1, 1, 2, 3] [100, 100, 100]
# [3, 2, 2, 2, 2, 2, 3]
# [3, 3, 3, 3, 3, 3, 3]
print('Pointwise addition of two kernels:')
pprint(kernel_a.add(kernel_b).getInfo())
# [3, 3, 3, 3, 3, 3, 3]
# [3, 2, 2, 2, 2, 2, 3]
# [3, 2, 101, 101, 101, 2, 3]
# [3, 2, 101, 100, 101, 2, 3]
# [3, 2, 101, 101, 101, 2, 3]
# [3, 2, 2, 2, 2, 2, 3]
# [3, 3, 3, 3, 3, 3, 3]
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[[["\u003cp\u003e\u003ccode\u003eKernel.add\u003c/code\u003e combines two kernels by adding their weights pointwise after aligning their centers.\u003c/p\u003e\n"],["\u003cp\u003eThe resulting kernel has the same dimensions as the larger of the two input kernels.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003enormalize\u003c/code\u003e parameter can be used to normalize the resulting kernel.\u003c/p\u003e\n"],["\u003cp\u003eKernels do not need to have the same dimensions to be added.\u003c/p\u003e\n"]]],[],null,["# ee.Kernel.add\n\nAdds two kernels (pointwise) after aligning their centers.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------------|---------|\n| Kernel.add`(kernel2, `*normalize*`)` | Kernel |\n\n| Argument | Type | Details |\n|-----------------|-------------------------|-----------------------|\n| this: `kernel1` | Kernel | The first kernel. |\n| `kernel2` | Kernel | The second kernel. |\n| `normalize` | Boolean, default: false | Normalize the kernel. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Two kernels, they do not need to have the same dimensions.\nvar kernelA = ee.Kernel.chebyshev({radius: 3});\nvar kernelB = ee.Kernel.square({radius: 1, normalize: false, magnitude: 100});\nprint(kernelA, kernelB);\n\n/**\n * Two kernel weights matrices\n *\n * [3, 3, 3, 3, 3, 3, 3]\n * [3, 2, 2, 2, 2, 2, 3]\n * [3, 2, 1, 1, 1, 2, 3] [100, 100, 100]\n * A [3, 2, 1, 0, 1, 2, 3] B [100, 100, 100]\n * [3, 2, 1, 1, 1, 2, 3] [100, 100, 100]\n * [3, 2, 2, 2, 2, 2, 3]\n * [3, 3, 3, 3, 3, 3, 3]\n */\n\nprint('Pointwise addition of two kernels', kernelA.add(kernelB));\n\n/**\n * [3, 3, 3, 3, 3, 3, 3]\n * [3, 2, 2, 2, 2, 2, 3]\n * [3, 2, 101, 101, 101, 2, 3]\n * [3, 2, 101, 100, 101, 2, 3]\n * [3, 2, 101, 101, 101, 2, 3]\n * [3, 2, 2, 2, 2, 2, 3]\n * [3, 3, 3, 3, 3, 3, 3]\n */\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nfrom pprint import pprint\n\n# Two kernels, they do not need to have the same dimensions.\nkernel_a = ee.Kernel.chebyshev(**{'radius': ee.Number(3)})\nkernel_b = ee.Kernel.square(**{\n 'radius': 1,\n 'normalize': False,\n 'magnitude': 100\n})\npprint(kernel_a.getInfo())\npprint(kernel_b.getInfo())\n\n# Two kernel weights matrices\n\n# [3, 3, 3, 3, 3, 3, 3]\n# [3, 2, 2, 2, 2, 2, 3]\n# [3, 2, 1, 1, 1, 2, 3] [100, 100, 100]\n# A [3, 2, 1, 0, 1, 2, 3] B [100, 100, 100]\n# [3, 2, 1, 1, 1, 2, 3] [100, 100, 100]\n# [3, 2, 2, 2, 2, 2, 3]\n# [3, 3, 3, 3, 3, 3, 3]\n\nprint('Pointwise addition of two kernels:')\npprint(kernel_a.add(kernel_b).getInfo())\n\n# [3, 3, 3, 3, 3, 3, 3]\n# [3, 2, 2, 2, 2, 2, 3]\n# [3, 2, 101, 101, 101, 2, 3]\n# [3, 2, 101, 100, 101, 2, 3]\n# [3, 2, 101, 101, 101, 2, 3]\n# [3, 2, 2, 2, 2, 2, 3]\n# [3, 3, 3, 3, 3, 3, 3]\n```"]]