Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
- Posts: 16
- Joined: 2012-12-06T17:56:02-07:00
- Authentication code: 6789
There is a nice app on my Android phone called OfficeLens. It allows you to compose a picture of a namecard or a sheet of paper, it detects the edges of the namecard/paper and automatically crops away the outside retaining just the internal of the card/paper when you snap the photo.
It seems to correctly detect if the phone is not perfectly aligned to the namecard, in yaw, pitch and roll and applies an appropriate transform to make the information in the namecard as perfect as possible.
I want to do the same with photos from my camera (due to higher resolution and better quality), using imagemagick. I have tried this:
Code: Select all
convert input.jpg -fuzz 30% -trim +repage output.jpg
However this will not compensate if the camera was slightly rotated along any of the 3 possible axes of rotation. Is there a way to reproduce the Office Lens functionality in imagemagick?
- Posts: 11204
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
With IM, you can (a) find the coordinates in the image of the corners of the paper, then (b) distort the image to put those corners at the corners of an image, so the image of the paper is now a rectangle.
Step (b) is very simple. Step (a) is more complex, depending on what assumptions you can make about how well-defined the corners are, and what the background is behind the paper.
Fred has some scripts for bash (eg http://www.fmwconcepts.com/imagemagick/ ... /index.php
); I have some for Windows.