Puedes calcular el gradiente de cada banda de una imagen con image.gradient().
Por ejemplo, el siguiente código calcula la magnitud y la dirección del gradiente de la banda pancromática de Landsat 8:
Ten en cuenta que gradient() genera dos bandas: el gradiente en la dirección X y el gradiente en la dirección Y. Como se muestra en el ejemplo, las dos direcciones se pueden combinar para obtener la magnitud y la dirección del gradiente. La magnitud debería verse como la Figura 1.
Figura 1: Magnitud del gradiente pancromático de las imágenes de Landsat 8 sobre el área de la bahía de San Francisco, California, EE.UU.
[null,null,["Última actualización: 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"]]