[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eEarth Engine provides several specialized edge detection algorithms, including Canny edge detection, Hough transform, and zero-crossing algorithms, for image processing tasks.\u003c/p\u003e\n"],["\u003cp\u003eThe Canny edge detection algorithm identifies edges by calculating gradient magnitude and suppressing those of smaller magnitudes, optionally using a Gaussian pre-filter to remove noise.\u003c/p\u003e\n"],["\u003cp\u003eThe Hough transform can be used for line extraction from edge detector results, enabling the identification of linear features in images.\u003c/p\u003e\n"],["\u003cp\u003eThe zero-crossing algorithm detects edges by identifying pixels where neighboring pixels have opposite signs, often applied to the second derivative of an image for enhanced edge detection.\u003c/p\u003e\n"],["\u003cp\u003eEarth Engine offers the flexibility to adjust parameters like thresholds and sigma values to fine-tune the performance of these algorithms for specific image analysis requirements.\u003c/p\u003e\n"]]],["Earth Engine offers specialized edge detection algorithms, including Canny edge detection, which uses filters to identify edges and compute gradient magnitudes, suppressing smaller ones. The Hough transform extracts lines from Canny results. `zeroCrossing()` detects edges by identifying pixels with sign changes relative to neighboring pixels. This can be applied to an image's second derivative using Gaussian kernels. The provided code examples demonstrate these techniques, using `CannyEdgeDetector`, `HoughTransform`, and `zeroCrossing()`, respectively.\n"],null,["# Edge detection\n\n[Edge detection](http://en.wikipedia.org/wiki/Edge_detection) is applicable\nto a wide range of image processing tasks. In addition to the edge detection kernels\ndescribed in the [convolutions section](/earth-engine/guides/image_convolutions), there are\nseveral specialized edge detection algorithms in Earth Engine. The Canny edge detection\nalgorithm [(Canny 1986)](http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4767851) uses four separate filters to identify the diagonal, vertical, and horizontal edges. The\ncalculation extracts the first derivative value for the horizontal and vertical directions\nand computes the gradient magnitude. Gradients of smaller magnitude are suppressed. To\neliminate high-frequency noise, optionally pre-filter the image with a Gaussian kernel.\nFor example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a Landsat 8 image, select the panchromatic band.\nvar image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318').select('B8');\n\n// Perform Canny edge detection and display the result.\nvar canny = ee.Algorithms.CannyEdgeDetector({\n image: image, threshold: 10, sigma: 1\n});\nMap.setCenter(-122.054, 37.7295, 10);\nMap.addLayer(canny, {}, 'canny');\n```\n\nNote that the `threshold` parameter determines the minimum gradient magnitude\nand the `sigma` parameter is the standard deviation (SD) of a Gaussian\npre-filter to remove high-frequency noise. For line extraction from an edge detector,\nEarth Engine implements the Hough transform\n[(Duda and Hart 1972)](http://dl.acm.org/citation.cfm?id=361242). Continuing the\nprevious example, extract lines from the Canny detector with:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Perform Hough transform of the Canny result and display.\nvar hough = ee.Algorithms.HoughTransform(canny, 256, 600, 100);\nMap.addLayer(hough, {}, 'hough');\n```\n\nAnother specialized algorithm in Earth Engine is `zeroCrossing()`. A\nzero-crossing is defined as any pixel where the right, bottom, or diagonal bottom-right\npixel has the opposite sign. If any of these pixels is of opposite sign, the current\npixel is set to 1 (zero-crossing); otherwise it's set to zero. To detect edges,\nthe zero-crossings algorithm can be applied to an estimate of the image second derivative.\nThe following demonstrates using `zeroCrossing()` for edge detection:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a Landsat 8 image, select the panchromatic band.\nvar image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318').select('B8');\nMap.addLayer(image, {max: 12000});\n\n// Define a \"fat\" Gaussian kernel.\nvar fat = ee.Kernel.gaussian({\n radius: 3,\n sigma: 3,\n units: 'pixels',\n normalize: true,\n magnitude: -1\n});\n\n// Define a \"skinny\" Gaussian kernel.\nvar skinny = ee.Kernel.gaussian({\n radius: 3,\n sigma: 1,\n units: 'pixels',\n normalize: true,\n});\n\n// Compute a difference-of-Gaussians (DOG) kernel.\nvar dog = fat.add(skinny);\n\n// Compute the zero crossings of the second derivative, display.\nvar zeroXings = image.convolve(dog).zeroCrossing();\nMap.setCenter(-122.054, 37.7295, 10);\nMap.addLayer(zeroXings.selfMask(), {palette: 'FF0000'}, 'zero crossings');\n```\n\nThe zero-crossings output for an area near the San Francisco, CA airport should look\nsomething like Figure 1.\nFigure 1. Zero-crossings output (red) with the Landsat 8 panchromatic band in the background for an area near the San Francisco, California airport (right)."]]