The shape and structure of 3d images