بدلاً من تحديد منطقة لإجراء عملية تقليل عليها، من الممكن أيضًا
تحديد منطقة مجاورة لتطبيق مُخفِّض. لتقليل المناطق المجاورة للصورة، استخدِم
image.reduceNeighborhood()
. في هذه الحالة، سيتم التخفيض
في نافذة منزلقة فوق صورة الإدخال، مع تحديد حجم النافذة وشكلها
باستخدام ee.Kernel
. سيكون الناتج من reduceNeighborhood()
هو
صورة أخرى، حيث تمثّل كل قيمة بكسل الناتج من عملية التقليل في
منطقة حول هذا البكسل في الصورة المُدخلة. يوضّح الشكل 1 هذا النوع من
التخفيضات.

reduceNeighborhood()
، حيث يتم تطبيق المُخفِّض
في نواة.على سبيل المثال، ننصحك باستخدام صور برنامج National Agriculture Imagery Program (NAIP) لقياس
الاختلافات في المناظر الطبيعية الناتجة عن قطع الأشجار في غابات أشجار السرو في كاليفورنيا.
على وجه التحديد، استخدِم التباين المعياري (SD) في منطقة مجاورة لتمثيل الفرق
في النسيج بين المنطقة المسجّلة (الجنوب الغربي من الصورة في الشكل 2) والمنطقة المحمية
(الشمال الشرقي من الصورة في الشكل 2). على سبيل المثال، للحصول على نسيج صورة "مؤشر الاختلاف النباتي القياسي" (NDVI) من NAIP، استخدِم reduceNeighborhood()
لاحتساب SD
في نطاق يحدّده نواة:
محرِّر الرموز البرمجية (JavaScript)
// Define a region in the redwood forest. var redwoods = ee.Geometry.Rectangle(-124.0665, 41.0739, -123.934, 41.2029); // Load input NAIP imagery and build a mosaic. var naipCollection = ee.ImageCollection('USDA/NAIP/DOQQ') .filterBounds(redwoods) .filterDate('2012-01-01', '2012-12-31'); var naip = naipCollection.mosaic(); // Compute NDVI from the NAIP imagery. var naipNDVI = naip.normalizedDifference(['N', 'R']); // Compute standard deviation (SD) as texture of the NDVI. var texture = naipNDVI.reduceNeighborhood({ reducer: ee.Reducer.stdDev(), kernel: ee.Kernel.circle(7), }); // Display the results. Map.centerObject(redwoods, 12); Map.addLayer(naip, {}, 'NAIP input imagery'); Map.addLayer(naipNDVI, {min: -1, max: 1, palette: ['FF0000', '00FF00']}, 'NDVI'); Map.addLayer(texture, {min: 0, max: 0.3}, 'SD of NDVI');
import ee import geemap.core as geemap
Colab (Python)
# Define a region in the redwood forest. redwoods = ee.Geometry.Rectangle(-124.0665, 41.0739, -123.934, 41.2029) # Load input NAIP imagery and build a mosaic. naip_collection = ( ee.ImageCollection('USDA/NAIP/DOQQ') .filterBounds(redwoods) .filterDate('2012-01-01', '2012-12-31') ) naip = naip_collection.mosaic() # Compute NDVI from the NAIP imagery. naip_ndvi = naip.normalizedDifference(['N', 'R']) # Compute standard deviation (SD) as texture of the NDVI. texture = naip_ndvi.reduceNeighborhood( reducer=ee.Reducer.stdDev(), kernel=ee.Kernel.circle(7) ) # Display the results. m = geemap.Map() m.center_object(redwoods, 12) m.add_layer(naip, {}, 'NAIP input imagery') m.add_layer( naip_ndvi, {'min': -1, 'max': 1, 'palette': ['FF0000', '00FF00']}, 'NDVI' ) m.add_layer(texture, {'min': 0, 'max': 0.3}, 'SD of NDVI') m
يتم تضمين أي بكسل له قيمة نواة غير صفرية في عملية الحساب. يتم استخدام معاملات kernel
تلقائيًا، ولكن يمكنك تغيير هذا السلوك باستخدام الوسيطة
inputWeight
. تتم مقارنة الصورة المُدخلة وreduceNeighborhood()
الناتج في الشكل 2.


reduceNeighborhood()
الإخراج باستخدام مُخفِّض انحراف قياسي