입니다.
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))임을 증명할 수있는 것으로 생각됩니다. 내가 아는 전부는 그것이 필요할 때 나를 위해 빨리 일했다는 것입니다.
목표는 무엇입니까? 섀도우 마스크를 만들려고하십니까? 당신이 그것으로 시작하는 것 같기 때문에. 그렇지 않다면, 당신은 무엇을 분류하려고합니까? – Pace
쉐도우 마스크의 오류를 줄이기 위해 그림자를 구름에 연관시키기 위해 노력하고있는 것은 무엇입니까? – WAF