Local and global energies for shape analysis in medical imaging