JuliaImages / JuliaImages/ImageTransformations.jl
The reference frame associated to an image is not the best one to perform a shear transformation
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 47
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
Shear transformations are defined here https://en.wikipedia.org/wiki/Shear_mapping.
using Images, CoordinateTransformations, ImageTransformations, Plots
function vertical_shear(α) #vertical shear because it preserves the direction e₂=[0,1]
M=[1 0; tan(α) 1]
LinearMap(M)
end
img = load("xorimg.png")

imgw = warp(img, vertical_shear(π/9), fillvalue=1)

Surprise!! The vertical shear acted as an horizontal shear transformation:
function horizontal_shear(α) #preserves the horizontal direction, [1,0]
M =[1 tan(α); 0 1]
LinearMap(M)
end
I spent two hours to find out why this simple linear map led to an unexpected effect.
Since the shear transformation reversed the vertical to the horizontal preserved direction,
and conversely, I concluded that in the warp implementation, the image is referenced by default to the system
of coordinates with origin at the upper-left corner, the left side is xaxis, and the top side is yaxis,
i.e. for a pixel in the position (i, j), x=i, y=j.
This particular system of coordinates works well in the case of rotations, because the rotation has no invariant direction.
But it doesn't work for a vertical and horizontal shear, because xaxis isn't associated to the horizontal direction, and yaxis to the vertical one.
In order to get the right shear, as well as any linear or affine transformation of an image,
that image should be referenced to the orthonormal frame with origin D, as in the next figure, xaxis Dxₚ,
yaxis Dyₚ

To check my hypothesis I wrote the same code in Python, to performe the shear transformation
via scipy.ndimage, and got the right transformed image.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the warp entry point in ImageTransformations.jl and trace how image coordinates and the LinearMap are interpreted. Compare the Julia vertical_shear and horizontal_shear examples with the shown results; done means the requested shear preserves the corresponding vertical or horizontal direction under the image reference frame.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100