Generalized getConnectedRegions to support multiple types of cells being treated as the boundry.