I have written an buggy implementation. The idea is:
  1. find the corners of the contour
  2. add them to the particle
  3. do it again
  4. up to idempotence

but it fails ...
An issue for me is how to handle the "don't care" points (pixels) with ndimage hit or miss operator.