É possível calcular o gradiente de cada banda de uma imagem com image.gradient().
Por exemplo, o código a seguir calcula a magnitude e a direção do gradiente da
banda pancromática do Landsat 8:
gradient() gera duas faixas: o gradiente na direção X e o
gradiente na direção Y. Como mostrado no exemplo, as duas direções podem ser combinadas para
obter a magnitude e a direção do gradiente. A magnitude deve ser semelhante à Figura 1.
Figura 1. Magnitude do gradiente pancromático para as imagens do Landsat 8 sobre a
área da Baía de São Francisco, Califórnia, EUA.
[null,null,["Última atualização 2025-02-18 UTC."],[[["The `image.gradient()` function in Google Earth Engine calculates the gradient of each band in an image, yielding X and Y direction components."],["By combining the X and Y gradient components, you can derive both the gradient magnitude and direction."],["The gradient magnitude represents the rate of change in pixel values, while the direction indicates the orientation of this change."],["Visualizing the gradient can highlight areas of rapid change in the image, such as edges and textures."],["This functionality is demonstrated using Landsat 8 panchromatic data, showcasing the gradient over the San Francisco Bay area."]]],["The `image.gradient()` function computes the gradient of each image band, outputting X and Y-direction gradients. The example loads a Landsat 8 panchromatic band image, calculates the X and Y gradients, then determines the gradient's magnitude by combining the squared X and Y values and the gradient's direction using `atan2` function. Finally, it displays the gradient and its direction, centered on San Francisco. The image gradient magnitude is then illustrated.\n"]]