ee.Algorithms.Image.Segmentation.SNIC

אשכולות של סופר-פיקסלים שמבוססים על SNIC (Simple Non-Iterative Clustering). הפונקציה מחזירה טווח של מזהי אשכולות ואת הממוצעים לכל אשכול עבור כל אחד מטווחים הקלט. אם לא מספקים את תמונת ה'זרעים' כקלט, הפלט יכלול פס 'זרעים' שמכיל את מיקומי הזרעים שנוצרו. ראו: Achanta, Radhakrishna and 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הריווח בין מיקומי הזרעים של הסופר-פיקסלים, בפיקסלים. אם מספקים תמונת 'זרעים', לא נוצרת רשת.
compactnessמספר ממשי (float), ברירת מחדל: 1גורם הדחיסות. ערכים גדולים יותר גורמים לאשכולות להיות קומפקטיים יותר (ריבועיים). אם מגדירים את הערך כ-0, השקלול של המרחק המרחבי מושבת.
connectivityמספר שלם, ברירת מחדל: 8קישוריות. ‫4 או 8.
neighborhoodSizeמספר שלם, ברירת מחדל: nullגודל השכונה של קטעי המפה (כדי להימנע מארטיפקטים בגבולות של קטעי המפה). ברירת המחדל היא 2 * גודל.
seedsתמונה, ברירת מחדל: nullאם מציינים ערך, כל הפיקסלים עם ערך שונה מאפס משמשים כמיקומי התחלה. פיקסלים שמשיקים (כפי שמצוין ב 'קישוריות') נחשבים כשייכים לאותו אשכול.

דוגמאות

עורך הקוד (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 Environment.

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