Skip to content
Discussion options

You must be logged in to vote

Thanks for trying image! The operation you are describing is called warp perspective and is implemented by the function Image.warp_perspective/4. Using your image as an example:

iex> image = Image.open!("path/image.jpg")
iex> warp_from = [{404,29},{1594,46},{1872,1225},{118,1224}]
iex> warp_to =  [{342,15},{1657,26},{1802,1151},{187,1140}]
iex> infill_pixel_color = [62,86,244]
iex> {:ok, warped} = Image.warp_perspective(image, warp_from, warp_to, background: infill_pixel_color)

Which produces:

Image perspective straightening

There is also a function Image.straighten_perspective/3 that tries to straighten the image. Which can than also be cropped. For example:

iex> {:ok, bounding_box, str…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by mrdotb
Comment options

You must be logged in to vote
2 replies
@kipcole9
Comment options

@mrdotb
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants