I don’t know whether that is easy using elastix, but it should not be hard using ITK directly. In your double for loop update the origin of the moving image, then manually evaluate the metric. See some related discussions, such as this and this.