ee.Kernel.add
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เพิ่ม 2 เคอร์เนล (แบบจุดต่อจุด) หลังจากจัดแนวศูนย์กลางแล้ว
การใช้งาน | การคืนสินค้า |
---|
Kernel.add(kernel2, normalize) | เคอร์เนล |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
ดังนี้ kernel1 | เคอร์เนล | เคอร์เนลแรก |
kernel2 | เคอร์เนล | เคอร์เนลที่ 2 |
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 Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[null,null,["อัปเดตล่าสุด 2025-07-27 UTC"],[[["\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```"]]