美文网首页GEE案例
GEE霍夫变换(hough transform)

GEE霍夫变换(hough transform)

作者: 赤豆冰棍 | 来源:发表于2019-01-04 01:05 被阅读0次

    霍夫变换

    主要功能

    使用霍夫变换,检测直线特征

    代码

    // An example finding linear features using the HoughTransform.
    
    // Load an image and compute NDVI.
    var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_033032_20170719');
    var ndvi = image.normalizedDifference(['B5', 'B4']);
    
    // Apply a Canny edge detector.
    var canny = ee.Algorithms.CannyEdgeDetector({
      image: ndvi,
      threshold: 0.4
    }).multiply(255);
    
    // Apply the Hough transform.
    var h = ee.Algorithms.HoughTransform({
      image: canny,
      gridSize: 256,
      inputThreshold: 50,
      lineThreshold: 100
    });
    
    // Display.
    Map.setCenter(-103.80140, 40.21729, 13);
    Map.addLayer(image, {bands: ['B4', 'B3', 'B2'], max: 0.3}, 'source_image');
    Map.addLayer(canny.updateMask(canny), {min: 0, max: 1, palette: 'blue'}, 'canny');
    Map.addLayer(h.updateMask(h), {min: 0, max: 1, palette: 'red'}, 'hough');
    

    步骤分析

    1. 创建ee对象,获取LC08数据
    2. 计算NDVI
    3. canny边缘检测
    4. 霍夫变换
    5. 设置地图中心,缩放等级
    6. 添加原始数据图层
    7. 显示canny边缘检测结果
    8. 显示霍夫变换检测结果

    主要方法

    1. ee.Algorithms.HoughTransform()
      Applies the Hough transform to an image. For every input band, outputs a band where lines are detected by thresholding the Hough transform with a value of lineThreshold. The output band is named [input]_lines, where [input] is the name of the original band. The defaults provided for the parameters are intended as a starting point for use with UINT8 images.
      Arguments:
      image (Image):
      The image to which to apply the transform.
      gridSize (Integer, default: 256):
      Grid size.
      inputThreshold (Float, default: 64):
      Value threshold for input image. Pixels equal to or above this value are considered active.
      lineThreshold (Float, default: 72):
      Threshold for line detection. Values equal to or above this threshold on the Hough transform are considered to be detected lines.
      smooth (Boolean, default: true):
      Whether to smooth the Hough transform before line detection.
      Returns: Image

    对输入影像对象执行霍夫变换。默认参数是针对无符号八位整型数据的。
    输入参数:输入影像对象,gridSize(格网大小,默认是256整数),inputThreshold(检测阈值),lineThreshold(线检测阈值),smooth(布尔型,默认为真)

    相关文章

      网友评论

        本文标题:GEE霍夫变换(hough transform)

        本文链接:https://www.haomeiwen.com/subject/pphcrqtx.html