Added new perimeter function based on the edges, not the inside ring of pixels.