Shape analysis of H ii regions – I. Statistical clustering