Convert photo to scanned image

999 views
Skip to first unread message

Milind Purohit

unread,
Jan 1, 2020, 3:01:08 AM1/1/20
to hugin and other free panoramic software
Frequently one needs a nicely scanned image of a document, but only a cell phone is handy.
It seems that Hugin can convert a photo of a page by appropriate stretching to a nicely rendered rectangular scanned image.
Is this possible, and if so how to do it? 

Thanks.

Harry van der Wolf

unread,
Jan 1, 2020, 3:38:48 AM1/1/20
to hugi...@googlegroups.com

Op wo 1 jan. 2020 om 09:01 schreef Milind Purohit <mpur...@gmail.com>:
--
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hugin-ptx+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hugin-ptx/5c24aa5e-62af-4178-b162-0f4606b9c040%40googlegroups.com.

Bruno Postle

unread,
Jan 1, 2020, 3:46:31 AM1/1/20
to hugi...@googlegroups.com
Yes, you can straighten a perspective photo of a document using Hugin's horizontal and vertical control points, and by setting both the input and output projection to 'rectilinear'.

But I don't use Hugin for this. I would open the photo in an image editor, such as GIMP, and use the 'perspective tool'.
If you are using GIMP, be sure to set the perspective tool to 'Corrective (Backward)', this way all you have to do is drag the four corners of the selection to the four corners of the paper.

Note that the GIMP documentation claims that it doesn't do true perspective. This is wrong, the GIMP homography distortion is identical to that provided by Hugin.

Happy new year! 🎉

--
Bruno

Daniel Md

unread,
Jan 1, 2020, 4:49:28 AM1/1/20
to hugi...@googlegroups.com
One more thing for doing this in Gimp is to first scale the image to the desired aspect ratio. 

--
A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ
---
You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hugin-ptx+...@googlegroups.com.

Jens Scheidtmann

unread,
Jan 1, 2020, 7:36:02 AM1/1/20
to hugi...@googlegroups.com
Hi Milind,

Check Office Lens from Microsoft (free as in beer) from the App Store. Greatly simplifies the workflow. 

Jens

Abrimaal

unread,
Jan 3, 2020, 3:12:52 PM1/3/20
to hugin and other free panoramic software
This is simple (quite) if you have a single image to straighten.
The image borders should differ from background.
Just draw short lines to mark the borders, then
- Projection / Rectilinear
- Edit / Fine tune all points
- Optimize / Positions view and barrel
- Save as panorama
Let's assume that the yellow box is the photographed document.
Auto-detection of vertical lines is not useful for this, because the lines are often too long.
This is a selective straightening, only on the yellow box, other parts of the image are useless here.
yelbox is straight the rest not important.png

John Muccigrosso

unread,
Mar 4, 2020, 6:19:00 PM3/4/20
to hugin and other free panoramic software
But I don't use Hugin for this. I would open the photo in an image editor, such as GIMP, and use the 'perspective tool'. 
If you are using GIMP, be sure to set the perspective tool to 'Corrective (Backward)', this way all you have to do is drag the four corners of the selection to the four corners of the paper. 

Trying to replicate this in GIMP on a photo I have that was taken of the ground at a sharp angle. What exactly do you mean by "the selection"?

Bruno Postle

unread,
Mar 5, 2020, 2:11:52 AM3/5/20
to hugi...@googlegroups.com
Gimp tools like the perspective tool operate on a rectangular area of the image. If you have selected an area to work on (using the lasoo tool or similar, surrounded by 'marching ants'), this rectangle fits the 'selection', otherwise the rectangle fits the whole layer or image.

--
Bruno

jmuc...@gmail.com

unread,
Mar 19, 2021, 2:53:27 PM3/19/21
to hugin and other free panoramic software
A little follow-up on this a year later...

A had a fairly distorted image that I tried to fix up using the techniques described here. You can see the results in the montage below. The first is the original photo; the second was produced with hugin 2020 (and contrast enhanced) and the third was produced with gimp. The hugin version is much superior to the one produced by gimp. I've had other photos that gimp did a fine job on, but not this one and I'm not sure why.
montage.jpg

Bruno Postle

unread,
Mar 20, 2021, 9:10:29 AM3/20/21
to hugi...@googlegroups.com
GIMP stretches the quadrilateral outline to the image (or selection) rectangle, so if you want the result to be long and thin then you need a long and thin canvas. Hugin understands about lens parameters, so as long as you know these accurately, you can reproject without distortion - Bruno

jmuc...@gmail.com

unread,
Mar 20, 2021, 9:14:49 AM3/20/21
to hugin and other free panoramic software
Ah, that makes sense. So gimp isn’t really a good substitute if you care about accurate proportions.
Reply all
Reply to author
Forward
0 new messages