Added algorithm to identify enclosed perimeters.