Perspective transform and clustering