如何改变拍下的文件看“扫描” [英] How to Alter Photographed Document to Look "Scanned"
问题描述
我怎样才能在Python / PIL中执行此操作?即,给定偏移矩形的四个点(拍摄的文档),使其看起来平坦,就好像它被扫描一样。它有一个简单的算法吗?
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"?
我想在Python中为自己制作这个程序的简单版本。
I want to make a simple version of this program for myself in Python.
推荐答案
看在transform()方法设置为QUAD
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.
数据是8元组(x0,y0,x1,y1,x2,y2,y3,y3),包含左上角,左下角,下角右边和源四边形的右上角。
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.
这篇关于如何改变拍下的文件看“扫描”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!