shape context implementation in python