Fix Array out of bound exception for image stitching