- Define a point queue Q
- Define a foreground point vector F
- Define a boundary point vector B
- Put starting point in Q
- While Q is not empty
- p = Q.top
- if p is foreground
- F.push(p)
- Q.push(neighbors of p)
- else
- B.push(p)
- Return size(F), size(B)
对于这个函数,我将从这个点开始增加一个区域。下面是一个伪代码:
最后,
F
包含前景像素,B
包含边界像素(黑色像素正好在白色像素之外)。因此,size(F)
给出了面积,size(B)
给出了周长。在相关问题 更多 >
编程相关推荐