ee.Image.neighborhoodToArray
Turns the neighborhood of each pixel in a scalar image into a 2D array. Axes 0 and 1 of the output array correspond to Y and X axes of the image, respectively. The output image will have as many bands as the input; each output band has the same mask as the corresponding input band. The footprint and metadata of the input image are preserved.
Usage | Returns |
---|
Image.neighborhoodToArray(kernel, defaultValue) | Image |
Argument | Type | Details |
---|
this: image | Image | The image to get pixels from; must be scalar-valued. |
kernel | Kernel | The kernel specifying the shape of the neighborhood. Only fixed, square and rectangle kernels are supported. Weights are ignored; only the shape of the kernel is used. |
defaultValue | Float, default: 0 | The value to use in the output arrays to replace the invalid (masked) pixels of the input. If the band type is integral, the fractional part of this value is discarded; in all cases, the value is clamped to the value range of the band. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["Transforms a scalar image into a 2D array representation of pixel neighborhoods."],["Output array dimensions align with the image's Y and X axes, maintaining the input's band count and mask."],["Utilizes a kernel to define neighborhood shape, with optional defaultValue for handling masked pixels."],["Preserves original image metadata and footprint for seamless integration into workflows."]]],["Transforms a scalar image by converting each pixel's neighborhood into a 2D array. The output array's axes 0 and 1 correspond to the image's Y and X axes, respectively. The method uses a `kernel` to define the neighborhood's shape (fixed, square, or rectangle). Invalid pixels within the input are replaced using a `defaultValue`. The input image's footprint, metadata, and mask are retained, but kernel weights are not considered. The method returns a new `Image`.\n"]]