การดำเนินการแบบมอร์ฟอลوجิก
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Earth Engine ใช้การดำเนินการทางสัณฐานวิทยาเป็นการดำเนินการโฟกัส โดยเฉพาะเมธอดอินสแตนซ์ focalMax()
, focalMin()
, focalMedian()
และ focalMode()
ในคลาส Image
(แป้นพิมพ์ลัดเหล่านี้เป็นแป้นพิมพ์ลัดสำหรับ reduceNeighborhood()
ทั่วไปมากขึ้น ซึ่งสามารถป้อนพิกเซลในเคอร์เนลไปยังตัวลดที่มีเอาต์พุตที่เป็นตัวเลข ดูข้อมูลเพิ่มเติมเกี่ยวกับการลดจำนวนย่านได้ในหน้านี้) โอเปอเรเตอร์เชิงมอร์ฟอลโลจีมีประโยชน์สำหรับการดำเนินการต่างๆ เช่น การกัดกร่อน การขยาย การปิด และการเปิด เช่น หากต้องการทำการดำเนินการเปิด ให้ใช้ focalMin()
ตามด้วย focalMax()
เครื่องมือแก้ไขโค้ด (JavaScript)
// Load a Landsat 8 image, select the NIR band, threshold, display.
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')
.select(4).gt(0.2);
Map.setCenter(-122.1899, 37.5010, 13);
Map.addLayer(image, {}, 'NIR threshold');
// Define a kernel.
var kernel = ee.Kernel.circle({radius: 1});
// Perform an erosion followed by a dilation, display.
var opened = image
.focalMin({kernel: kernel, iterations: 2})
.focalMax({kernel: kernel, iterations: 2});
Map.addLayer(opened, {}, 'opened');
โปรดทราบว่าในตัวอย่างนี้ จะมีการระบุอาร์กิวเมนต์เคอร์เนลให้กับโอเปอเรเตอร์เชิงมอร์ฟอลโลจี ระบบจะใช้พิกเซลที่องค์ประกอบของ Kernel ไม่ใช่ 0 ในการคำนวณ อาร์กิวเมนต์ "จำนวนรอบ" ระบุจํานวนครั้งที่จะใช้โอเปอเรเตอร์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003eEarth Engine uses focal operations like \u003ccode\u003efocalMax()\u003c/code\u003e, \u003ccode\u003efocalMin()\u003c/code\u003e, \u003ccode\u003efocalMedian()\u003c/code\u003e, and \u003ccode\u003efocalMode()\u003c/code\u003e to implement morphological operations for image processing.\u003c/p\u003e\n"],["\u003cp\u003eMorphological operations, such as erosion, dilation, opening, and closing, can be performed using these focal operations to modify image structures.\u003c/p\u003e\n"],["\u003cp\u003eUsers can define kernels to specify the shape and size of the neighborhood used in the operations and control the number of times the operation is applied with the iterations argument.\u003c/p\u003e\n"],["\u003cp\u003eAn opening operation, for example, can be achieved by applying \u003ccode\u003efocalMin()\u003c/code\u003e followed by \u003ccode\u003efocalMax()\u003c/code\u003e with a defined kernel.\u003c/p\u003e\n"]]],["Earth Engine's `Image` class provides `focalMax()`, `focalMin()`, `focalMedian()`, and `focalMode()` for morphological operations like erosion, dilation, opening, and closing. These operations use a kernel to define the neighborhood of pixels. For example, the opening operation is achieved by applying `focalMin()` then `focalMax()`. A kernel argument defines the area for computation, and the iterations argument specifies the number of operator applications. The provided code demonstrates the opening operation on a Landsat 8 image using a circular kernel.\n"],null,["# Morphological Operations\n\nEarth Engine implements morphological operations as focal operations, specifically\n`focalMax()`, `focalMin()`, `focalMedian()`, and\n`focalMode()` instance methods in the `Image` class. (These are\nshortcuts for the more general `reduceNeighborhood()`, which can input the\npixels in a kernel to any reducer with a numeric output. See\n[this page](/earth-engine/guides/reducers_reduce_neighborhood) for more information on reducing\nneighborhoods). The morphological operators are useful for performing operations such\nas erosion, dilation, opening and closing. For example, to perform an\n[opening operation](http://en.wikipedia.org/wiki/Opening_(morphology)),\nuse `focalMin()` followed by `focalMax()`:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a Landsat 8 image, select the NIR band, threshold, display.\nvar image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')\n .select(4).gt(0.2);\nMap.setCenter(-122.1899, 37.5010, 13);\nMap.addLayer(image, {}, 'NIR threshold');\n\n// Define a kernel.\nvar kernel = ee.Kernel.circle({radius: 1});\n\n// Perform an erosion followed by a dilation, display.\nvar opened = image\n .focalMin({kernel: kernel, iterations: 2})\n .focalMax({kernel: kernel, iterations: 2});\nMap.addLayer(opened, {}, 'opened');\n```\n\nNote that in the previous example, a kernel argument is provided to the morphological\noperator. The pixels covered by non-zero elements of the kernel are used in the\ncomputation. The iterations argument indicates how many times to apply the operator."]]