Statistics-based chain code compression with decreased sensitivity to shape artefacts