ee.Algorithms.Image.Segmentation.SNIC

خوشه بندی سوپرپیکسلی بر اساس SNIC (خوشه بندی ساده غیر تکراری). خروجی باندی از شناسه های خوشه و میانگین های هر خوشه برای هر یک از باندهای ورودی. اگر تصویر "seeds" به عنوان ورودی ارائه نشود، خروجی شامل یک نوار "seeds" حاوی مکان‌های بذر تولید شده خواهد بود. نگاه کنید به: 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 فاصله مکان بذر سوپرپیکسل، بر حسب پیکسل. اگر تصویر "seeds" ارائه شود، هیچ شبکه ای تولید نمی شود.
compactness شناور، پیش فرض: 1 ضریب فشردگی مقادیر بزرگتر باعث می شود که خوشه ها فشرده تر (مربع) شوند. تنظیم این روی 0 وزن فاصله مکانی را غیرفعال می کند.
connectivity عدد صحیح، پیش فرض: 8 قابلیت اتصال یا 4 یا 8.
neighborhoodSize عدد صحیح، پیش فرض: null اندازه محله کاشی (برای جلوگیری از مصنوعات مرز کاشی). اندازه پیش‌فرض 2 * است.
seeds تصویر، پیش فرض: null در صورت ارائه، هر پیکسل با ارزش غیر صفر به عنوان مکان بذر استفاده می شود. پیکسل‌هایی که لمس می‌شوند (همانطور که توسط «اتصال» مشخص شده است) متعلق به یک خوشه در نظر گرفته می‌شوند.

نمونه ها

ویرایشگر کد (جاوا اسکریپت)

// 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');

راه اندازی پایتون

برای اطلاعات در مورد API پایتون و استفاده از geemap برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.

import ee
import geemap.core as geemap

کولب (پایتون)

# 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