ee.Image.reduceNeighborhood
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Áp dụng hàm giảm đã cho cho vùng lân cận xung quanh mỗi pixel, theo xác định của hạt nhân đã cho. Nếu hàm giảm có một đầu vào, thì hàm này sẽ được áp dụng riêng cho từng dải của tập hợp; nếu không, hàm này phải có cùng số lượng đầu vào như hình ảnh đầu vào có các dải.
Tên đầu ra của hàm giảm xác định tên của các dải đầu ra: các hàm giảm có nhiều đầu vào sẽ sử dụng trực tiếp tên đầu ra, trong khi các hàm giảm có một đầu vào sẽ thêm tên dải đầu vào vào tên đầu ra (ví dụ: '10_mean', '20_mean').
Các hàm rút gọn có đầu vào được tính trọng số có thể có trọng số đầu vào dựa trên mặt nạ đầu vào, giá trị hạt nhân hoặc giá trị nhỏ hơn trong hai giá trị đó.
Cách sử dụng | Giá trị trả về |
---|
Image.reduceNeighborhood(reducer, kernel, inputWeight, skipMasked, optimization) | Hình ảnh |
Đối số | Loại | Thông tin chi tiết |
---|
this: image | Hình ảnh | Hình ảnh đầu vào. |
reducer | Bộ giảm tốc | Bộ giảm để áp dụng cho các pixel trong vùng lân cận. |
kernel | Kernel | Hạt nhân xác định vùng lân cận. |
inputWeight | Chuỗi, mặc định: "kernel" | Một trong các giá trị "mask", "kernel" hoặc "min". |
skipMasked | Boolean, mặc định: true | Che các pixel đầu ra nếu pixel đầu vào tương ứng bị che. |
optimization | Chuỗi, mặc định: null | Chiến lược tối ưu hoá. Các lựa chọn là "boxcar" và "window". Phương thức "boxcar" là một phương thức nhanh chóng để tính số lượng, tổng hoặc giá trị trung bình. Nó yêu cầu một hạt nhân đồng nhất, một bộ giảm đầu vào duy nhất và MASK, KERNEL hoặc không có trọng số. Phương thức "window" (cửa sổ) sử dụng một cửa sổ đang chạy và có các yêu cầu tương tự như "boxcar" (toa xe), nhưng có thể sử dụng bất kỳ bộ giảm đầu vào đơn lẻ nào. Cả hai phương pháp này đều cần thêm một lượng đáng kể bộ nhớ. |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eApplies a given reducer function to the neighborhood of each pixel, defined by a kernel.\u003c/p\u003e\n"],["\u003cp\u003eOutput band names are determined by the reducer's output names, prefixed with the input band name for single-input reducers.\u003c/p\u003e\n"],["\u003cp\u003eInput weight for reducers can be based on the mask, kernel value, or the minimum of the two.\u003c/p\u003e\n"],["\u003cp\u003eOffers optimization strategies like 'boxcar' and 'window' for specific reducer and kernel types to improve performance.\u003c/p\u003e\n"],["\u003cp\u003eAllows skipping computation on masked pixels for efficiency.\u003c/p\u003e\n"]]],["This operation applies a reducer to pixel neighborhoods defined by a kernel. The reducer can have single or multiple inputs, with output band names determined accordingly. Weighted inputs are supported based on the input mask, kernel value, or their minimum. Options are available to skip masked pixels and optimize the process. The `Image.reduceNeighborhood` function takes a reducer, kernel, input weight, skip masked option, and an optimization method, returning a new image.\n"],null,["# ee.Image.reduceNeighborhood\n\nApplies the given reducer to the neighborhood around each pixel, as determined by the given kernel. If the reducer has a single input, it will be applied separately to each band of the collection; otherwise it must have the same number of inputs as the input image has bands.\n\n\u003cbr /\u003e\n\nThe reducer output names determine the names of the output bands: reducers with multiple inputs will use the output names directly, while reducers with a single input will prefix the output name with the input band name (e.g., '10_mean', '20_mean').\n\nReducers with weighted inputs can have the input weight based on the input mask, the kernel value, or the smaller of those two.\n\n| Usage | Returns |\n|--------------------------------------------------------------------------------------------------|---------|\n| Image.reduceNeighborhood`(reducer, kernel, `*inputWeight* `, `*skipMasked* `, `*optimization*`)` | Image |\n\n| Argument | Type | Details |\n|----------------|---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `image` | Image | The input image. |\n| `reducer` | Reducer | The reducer to apply to pixels within the neighborhood. |\n| `kernel` | Kernel | The kernel defining the neighborhood. |\n| `inputWeight` | String, default: \"kernel\" | One of 'mask', 'kernel', or 'min'. |\n| `skipMasked` | Boolean, default: true | Mask output pixels if the corresponding input pixel is masked. |\n| `optimization` | String, default: null | Optimization strategy. Options are 'boxcar' and 'window'. The 'boxcar' method is a fast method for computing count, sum or mean. It requires a homogeneous kernel, a single-input reducer and either MASK, KERNEL or no weighting. The 'window' method uses a running window, and has the same requirements as 'boxcar', but can use any single input reducer. Both methods require considerable additional memory. |"]]