Page 1 of 1

crop and deskew based on coordinates only?

Posted: 2019-08-09T01:54:05-07:00
by dannyler
hi all!

i have to preface as a first time poster, that in the last years I have only used imagemagick to convert, resize, annotate images. quite a lot, but never to do anything more sophisticated with it. and now i'm failing to comprehend what to do completely.

i'm trying to get an image deskewed, but based on coordinates. and I don't know if i use the wrong keywords to search in google or if I need a whole different approach, but this is what I have:

step 1: detect books on images
step 2: identify the corners of the book
step 3: create a new image that is only the book, but deskewed, meaning as a rectangle

I've made my way up to step 2, but utterly fail on step 3.

is it multiple commands in a row, is it one?
is it possible with ImageMagick at all?
can somepoint point me in the right direction?

example image annotated: https://imgur.com/a/DhrwErL
edit: desired target output: https://imgur.com/a/4Njw3rU

much appreciated, thank you!
Dan

Re: crop and deskew based on coordinates only?

Posted: 2019-08-09T07:08:10-07:00
by snibgo
You know the coordinates of four points (this is 8 numbers). You want to move those four points to some other coordinates (another 8 numbers). For that, use "-distort perspective". Give that 16 numbers, in this order:

x,y coords of first input point
x,y coords for desired location of first point
x,y coords of second input point
x,y coords for desired location of second point
x,y coords of third input point
x,y coords for desired location of third point
x,y coords of fourth input point
x,y coords for desired location of fourth point

See http://www.imagemagick.org/script/comma ... hp#distort