# Warp images and coordinates

I’m transforming an image using `ImageTransformations.wrap`, but I also want to use the same transformation to transform some coordinates. The idea is that a coordinate in the original image should be transformed to a coordinate in the warped image.

MWE:

``````using Images, CoordinateTransformations, Rotations, ImageView, ImageDraw, TestImages
img = testimage("lighthouse")
i = [350, 57] # the top of the lightning rod
draw!(img, Cross(Point(i...), 10), RGB{N0f8}(1)) # mark it with an +
t = recenter(RotMatrix(π/4), center(img)) # rotate 45° around the center
invt = inv(t)
imgw = warp(img, t)
iw = round.(Int, t(i)) # transform the lightning-rod coordinate as well (convert to Int too)
iiw = round.(Int, invt(i)) # inverse transform the lightning-rod coordinate as well (convert to Int too)
draw!(imgw, Cross(Point(iw...), 10), RGB{N0f8}(1,0,0)) # draw that same location again?
draw!(imgw, Cross(Point(i...), 10), RGB{N0f8}(0,1,0)) # draw that same location again?
draw!(imgw, Cross(Point(iiw...), 10), RGB{N0f8}(0,0,1)) # draw that same location again?
imshow(imgw) # no...
``````

After rereading the excellent and clear blogpost by Tim Holy:

I still can’t get this to work:

How do I transform the original coordinates, `[350, 57]`, to where the top of the lightning-rod is in the transformed image (so where the white plus-sign is in the above image)?

Ah… `ImageDraw.Point`'s notion of x and y is different from the coordinates ImageTransformations.warp accepts. So by flipping x and y I got it to work:

``````iiw = round.(Int, reverse(invt(reverse(i)))) # inverse transform the lightning-rod coordinate as well (convert to Int too)
draw!(imgw, Cross(Point(iiw...), 10), RGB{N0f8}(0,0,1)) # draw that same location again?
``````