Changed perimeter test to 8 connected chain code algo