I digitalized several big books with a camera (~1000 photos), using a green background. I would like to make them more readable.
Original photos looks like this (this is an example, not the real books, which are much bigger) :

I first extracted a mask representing the shape of the book:
Code: Select all
convert original.jpg -fuzz 25% -fill None -floodfill +0+0 '#0a613e' -alpha extract -morphology Open Disk mask.png

Using this shape, I keep only the book, and I also crop an resize the pic:
Code: Select all
convert original.jpg -compose CopyOpacity mask.png -composite -trim +repage -resize 600 output.png

My question is: Is it possible, using the mask, to distort the pic by moving the extremities of the book in the extremities of the picture, in order to have a "flat book" aspect, so the text would be in straight lines (like if I used a scanner) ?
Shepards Distortion ? I don't really know how to use them for my purpose... I think to write a script to get all dots of the mask perimeter and generate a very long im command, but is there a easier way?