Shape discrimination algorithm