Fixed perimeter calculation
Add +1 to Feret Calculation since images are zero based.

A 100x100 pixel image goes from 0,0 to 99,99. Therefor Math.abs(x2-x1) + 1 must be used to get the length of 100 for one side.
add zero check before division