How to Alter Photographed Document to Look “Scanned”

久未见 提交于 2019-12-04 22:44:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/662638/how-to-alter-photographed-document-to-look-scanned

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!