Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Alter Photographed Document to Look "Scanned"

How can I do this in Python/PIL? I.e., given the four points of an offset rectangle (a photographed document), make it look flat on as if it were scanned. Is there a simple algorithm for it?

Also, are there any other manipulations I should do to make it look more "scan-like"?

I want to make a simple version of this program for myself in Python.

like image 877
Greg Avatar asked Mar 19 '09 15:03

Greg


People also ask

Can I scanned document be altered?

Optical character recognition, or OCR, is a widespread technology that allows you to scan documents and turn them into editable soft copy documents that you can then easily edit. Plenty of software makers offer OCR, such as Adobe OCR. Microsoft is one of those software makers.


1 Answers

Look at transform() with method set to QUAD

http://effbot.org/imagingbook/image.htm

im.transform(size, QUAD, data) => image
im.transform(size, QUAD, data, filter) => image

Maps a quadrilateral (a region defined by four corners) from the image to a rectangle with the given size.

Data is an 8-tuple (x0, y0, x1, y1, x2, y2, y3, y3) which contain the upper left, lower left, lower right, and upper right corner of the source quadrilateral.

like image 170
Lou Franco Avatar answered Oct 11 '22 12:10

Lou Franco