ประกาศ: โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดที่ลงทะเบียนเพื่อใช้ Earth Engine ก่อนวันที่
15 เมษายน 2025 ต้อง
ยืนยันการมีสิทธิ์ที่ไม่ใช่เชิงพาณิชย์เพื่อรักษาสิทธิ์เข้าถึง หากคุณไม่ยืนยันภายในวันที่ 26 กันยายน 2025 ระบบอาจระงับสิทธิ์เข้าถึงของคุณ
ee.Algorithms.Image.Segmentation.SNIC
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การจัดกลุ่ม Superpixel ตาม SNIC (การจัดกลุ่มแบบไม่วนซ้ำอย่างง่าย) เอาต์พุตเป็นแถบของรหัสคลัสเตอร์และค่าเฉลี่ยต่อคลัสเตอร์สำหรับแต่ละแถบอินพุต หากไม่ได้ระบุรูปภาพ "เมล็ด" เป็นอินพุต เอาต์พุตจะมีแถบ "เมล็ด" ที่มีตำแหน่งเมล็ดที่สร้างขึ้น ดู Achanta, Radhakrishna และ Susstrunk, Sabine, "Superpixels and Polygons using Simple Non-Iterative Clustering", CVPR, 2017
| การใช้งาน | การคืนสินค้า |
|---|
ee.Algorithms.Image.Segmentation.SNIC(image, size, compactness, connectivity, neighborhoodSize, seeds) | รูปภาพ |
| อาร์กิวเมนต์ | ประเภท | รายละเอียด |
|---|
image | รูปภาพ | รูปภาพอินพุตสำหรับการจัดกลุ่ม |
size | จำนวนเต็ม ค่าเริ่มต้น: 5 | ระยะห่างของตำแหน่งเริ่มต้นของ Superpixel ในหน่วยพิกเซล หากระบุรูปภาพ "เริ่มต้น" ระบบจะไม่สร้างตาราง |
compactness | Float, ค่าเริ่มต้น: 1 | ปัจจัยความกระชับ ค่ายิ่งมาก คลัสเตอร์ก็จะยิ่งกะทัดรัด (สี่เหลี่ยมจัตุรัส) การตั้งค่านี้เป็น 0 จะปิดใช้การให้น้ำหนักตามระยะทางเชิงพื้นที่ |
connectivity | จำนวนเต็ม ค่าเริ่มต้น: 8 | การเชื่อมต่อ 4 หรือ 8 |
neighborhoodSize | จำนวนเต็ม ค่าเริ่มต้น: null | ขนาดพื้นที่ใกล้เคียงของไทล์ (เพื่อหลีกเลี่ยงอาร์ติแฟกต์ขอบเขตของไทล์) ค่าเริ่มต้นคือ 2 * ขนาด |
seeds | รูปภาพ (ค่าเริ่มต้น): null | หากระบุไว้ ระบบจะใช้พิกเซลที่มีค่าที่ไม่ใช่ 0 เป็นตำแหน่งเริ่มต้น พิกเซลที่สัมผัสกัน (ตามที่ระบุโดย "การเชื่อมต่อ") จะถือว่าอยู่ในคลัสเตอร์เดียวกัน |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (JavaScript)
// Note that the compactness and size parameters can have a significant impact
// on the result. They must be adjusted to meet image-specific characteristics
// and patterns, typically through trial. Pixel scale (map zoom level) is also
// important to consider. When exploring interactively through map tile
// visualization, the segmentation result it dependent on zoom level. If you
// need to evaluate the result at a specific scale, call .reproject() on the
// result, but do so with caution because it overrides the default scaling
// behavior that makes tile computation fast and efficient.
// Load a NAIP image for a neighborhood in Las Vegas.
var naip = ee.Image('USDA/NAIP/DOQQ/m_3611554_sw_11_1_20170613');
// Apply the SNIC algorithm to the image.
var snic = ee.Algorithms.Image.Segmentation.SNIC({
image: naip,
size: 30,
compactness: 0.1,
connectivity: 8,
});
// Display the original NAIP image as RGB.
// Lock map zoom to maintain the desired scale of the segmentation computation.
Map.setLocked(false, 18, 18);
Map.setCenter(-115.32053, 36.182016, 18);
Map.addLayer(naip, null, 'NAIP RGB');
// Display the clusters.
Map.addLayer(snic.randomVisualizer(), null, 'Clusters');
// Display the RGB cluster means.
var visParams = {
bands: ['R_mean', 'G_mean', 'B_mean'],
min: 0,
max: 255
};
Map.addLayer(snic, visParams, 'RGB cluster means');
การตั้งค่า Python
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
# Note that the compactness and size parameters can have a significant impact
# on the result. They must be adjusted to meet image-specific characteristics
# and patterns, typically through trial. Pixel scale (map zoom level) is also
# important to consider. When exploring interactively through map tile
# visualization, the segmentation result it dependent on zoom level. If you
# need to evaluate the result at a specific scale, call .reproject() on the
# result, but do so with caution because it overrides the default scaling
# behavior that makes tile computation fast and efficient.
# Load a NAIP image for a neighborhood in Las Vegas.
naip = ee.Image('USDA/NAIP/DOQQ/m_3611554_sw_11_1_20170613')
# Apply the SNIC algorithm to the image.
snic = ee.Algorithms.Image.Segmentation.SNIC(
image=naip, size=30, compactness=0.1, connectivity=8
)
# Display the original NAIP image as RGB.
m = geemap.Map()
m.set_center(-115.32053, 36.182016, 18)
m.add_layer(naip, None, 'NAIP RGB')
# Display the clusters.
m.add_layer(snic.randomVisualizer(), None, 'Clusters')
# Display the RGB cluster means.
vis_params = {'bands': ['R_mean', 'G_mean', 'B_mean'], 'min': 0, 'max': 255}
m.add_layer(snic, vis_params, 'RGB cluster means')
m
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[],["SNIC clustering segments an image into superpixels, outputting cluster IDs and per-cluster averages for each input band. Key parameters include `size` (seed spacing), `compactness` (cluster shape), and `connectivity`. A user can provide `seeds` to define seed locations; otherwise, they are generated. The output `Image` includes cluster IDs, band averages, and optionally generated seed locations. Adjusting `size` and `compactness` is crucial for optimal results, which are also affected by pixel scale.\n"]]