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).

 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:

  AffineTransform[{{{1, 0}, {0, -1}}, {0, 0}}]],
 PlotRange -> {{-1, 1}, {-1, 1}}]

But that simply does not work.

  • 4
    $\begingroup$ 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. $\endgroup$ – J. M.'s technical difficulties Nov 13 '19 at 7:06
  • $\begingroup$ @J.M.willbebacksoon: You were right. After I dug around I finally figured out how to use DataRange within ImageTransformation. Thanks so much! $\endgroup$ – David G. Stork Nov 13 '19 at 8:13
  • $\begingroup$ does PlotRange -> All work? $\endgroup$ – kglr Nov 13 '19 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.