Added dynamic center finding for images