The function should just pad at the edges of the original image if need.