can counting contiguous regions in a bitmap be improved over O(r * c)?

前端 未结 5 1087
南笙
南笙 2021-02-15 16:52

You are given an image of a surface photographed by a satellite.The image is a bitmap where water is marked by \'.\' and land is marked by \'*\'. Adjacent group of

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-15 17:33

    This is highly related to connected component labeling. The number of connected component is just a byproduct of the labeling. Algorithm described in the linked wikipedia article works in linear time.

提交回复
热议问题