The corners of this polygon sit on grid points. Count the grid points inside it (I) and on its boundary (B).
The source code is at github.com/KirillOsenkov/LiveGeometry. It is written in .NET and Avalonia.