Fix dtype bug in perimeter