# Setting the location of the origin within an image for AffineTransformation

This question is closely related to this one, but slightly different.

I want to perform several AffineTransforms on an image (myImage). For example, here is a mirror reflection across the $$x$$ axis (i.e., each $$y$$ value is inverted).

ImageTransformation[myImage,
AffineTransform[{{{1, 0}, {0, -1}}, {0, 0}}]]


The problem is that the origin of the coordinate system is at the lower-left corner of the image. Thus the above transform reflects the image "out of bounds" (out of the plot range). It is extremely awkward to set plot ranges and such. Much simpler (mathematically, at least) would be to set the origin in the middle of the image, so that numerous calls to AffineTransform (and compounded transforms) all assume the origin is in the middle of the initial image (or the region transformed).

Alas, I don't see how I can do that.

For instance, one might think that one could flip the image (to -1) and set the PlotRange as here:

Show[ImageTransformation[myImage,
AffineTransform[{{{1, 0}, {0, -1}}, {0, 0}}]],
PlotRange -> {{-1, 1}, {-1, 1}}]


But that simply does not work.

• Have you looked into the DataRange and PlotRange options of ImageTransformation[]? You claim that "it is extremely awkward to set plot ranges and such" but it is not clear to me why you believe this to be the case. – J. M.'s technical difficulties Nov 13 '19 at 7:06
• @J.M.willbebacksoon: You were right. After I dug around I finally figured out how to use DataRange within ImageTransformation. Thanks so much! – David G. Stork Nov 13 '19 at 8:13
• does PlotRange -> All work? – kglr Nov 13 '19 at 10:41