1

我有两个光栅。第一个对应云遮罩,即像素对应云时为1,不对应时为0。第二个是阴影遮罩,如果像素被分类为阴影,则为 1,否则为 0。

为了减少与阴影分类相关的错误,可以使用阴影必须与云相关联这一事实。在某个方向上每个云的 x 米内必须有一个阴影(由于太阳角可以恢复)。

关于如何实施此关联步骤的任何想法?

这是原始图像的快照,云遮罩(白色)和阴影遮罩(黑色)在此处输入图像描述

4

1 回答 1

1

我已经看到这是通过队列完成的。本质上,伪代码看起来像:

points = new list()
queue = new queue()
for x,y in image_coordinates:
  if is_cloud(x,y):
    point = new point(x=x, y=y, distance=0, cloud_x=x, cloud_y=y)
    queue.push(point)
  else:
    point = new point(x=x, y=y, distance=null, could_x=null, cloud_y=null)
  points.push(point)

while(!queue.is_empty()):
  point = queue.pop()
  for neighbor in point.neighbors():
    if angle_is_correct(point.cloud_x, point.cloud_y, neighbor.point.x, neighbor.point.y):
      if neighbor.is_direct(): //N,S,E,W
        new_distance = point.distance + 1
      else: //NE, SE, SW, NW
        new_distance = point.distance + SQRT_2
      if neighbor.point.distance == null or neighbor.point.distance > new_distance:
        neighbor.point.distance = new_distance
        neighbor.point.cloud_x = point.cloud_x
        neighbor.point.cloud_y = point.cloud_y
      queue.push(neighbor.point)

运行完成后,点将是 x,y 坐标列表、它们与最近云的距离以及最近云的 x,y 坐标(您可能不需要)。您应该使用该angle_is_correct功能确保只考虑方向正确的云。如果距离超过最大距离,您还可以进一步优化它以停止将点添加到队列中。

我不完全确定算法的复杂性,但我怀疑有人可以设计一个证明来证明这是 O(n) 或 O(log(n))。我所知道的是,当我需要它时,它对我很快就起作用了。

于 2014-02-12T16:03:03.270 回答