{ "info": { "author": "Bohumir Zamecnik", "author_email": "bohumir.zamecnik@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7" ], "description": "# Document whitening (foreground separation)\n\nThis package tries to separate text/line foreground and background by 2D median\nfilter.\n\n\"original\"\n\"foreground\"\n\"background\"\n\n## Installation\n\nInstall from PyPI. Works on Python 3.\n\n```bash\npip install whitening\n```\n\n## Example usage\n\n### Python API\n\nIt works with images represented as `PIL.Image` or as a numpy array. Images can\nbe either RGB or grayscale.\n\n```python\nimport numpy as np\nimport PIL.Image\n\nfrom whitening import whiten\n\n# possible to use numpy array as input/output\nimage = np.asarray(PIL.Image.open('image.jpg'), dtype='uint8')\nforeground, background = whiten(image, kernel_size=20, downsample=4)\nPIL.Image.fromarray(foreground).save('foreground.jpg', 'jpeg')\n\n# or directly a PIL image\nimage = PIL.Image.open('image.jpg')\nforeground, background = whiten(image, kernel_size=20, downsample=4)\nforeground.save('foreground.jpg', 'jpeg')\n```\n\n### CLI\n\nIt install an entry point called `whiten`.\n\n```bash\n# help\n$ whiten -h\n\n# whiten an image and save the foreground output\n$ whiten input.jpg foreground.jpg\n\n# specify the kernel size\n$ whiten input.jpg foreground.jpg -k 100\n\n# work in grayscale instead of RGB (3x faster)\n$ whiten input.jpg foreground.jpg -g\n\n# downsample the image 4x (faster, but a bit less precise)\n$ whiten input.jpg foreground.jpg -d 4\n\n# save also the background\n$ whiten input.jpg foreground.jpg -b background.jpg\n```\n\nWe assume the original images is a product of foreground and background,\nthus we can recover the foreground by dividing the image by the background:\n`I = F * B => F = I / B`. We try to approximate the background by 2D median\nfiltering the original image which suppresses sparse features such as text and\nlines.\n\nSelect kernel size that's enough for not making artifacts while small enough\nto keep computation fast. A good starting point is 50 pixels.\n\nA 9.5 Mpx image can be processed on a MacBook in 15 s, with grayscale and\ndownsampling 4x the run time can be reduced to 1 s! Quite good results can be\nobtained even with kernel size 10 and downsampling 16x.\n\nMore info: http://bohumirzamecnik.cz/blog/2015/image-whitening/\n\n## Development\n\nSee the `Makefile` for various development tasks.\n\n## License\n\nAuthor: Bohum\u00edr Z\u00e1me\u010dn\u00edk \n\nSupported by [Rossum](https://rossum.ai), creating a world without manual data entry.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rossumai/whitening", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "whitening", "package_url": "https://pypi.org/project/whitening/", "platform": "", "project_url": "https://pypi.org/project/whitening/", "project_urls": { "Homepage": "https://github.com/rossumai/whitening" }, "release_url": "https://pypi.org/project/whitening/0.1/", "requires_dist": [ "numpy", "Pillow", "scikit-image", "scipy", "pytest ; extra == 'test'" ], "requires_python": "", "summary": "Document whitening (foreground separation)", "version": "0.1" }, "last_serial": 5836272, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "0867d3ba4b41ca3fca3ca378c92b83af", "sha256": "cc061d7a936d43fca47a4bbf53ca221e00ca911c00623b46ac048183e4444947" }, "downloads": -1, "filename": "whitening-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0867d3ba4b41ca3fca3ca378c92b83af", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5452, "upload_time": "2019-09-16T13:31:42", "url": "https://files.pythonhosted.org/packages/66/c0/7f4d2e677a6a5decde2b199a3fb85f679ac0291b2eb6e12465c7bf96b222/whitening-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "84a61e1b2e110c538394fd300dec11d4", "sha256": "afa89e2281b59741b17c22a25e7a0badcaf39e16130b97543ae0b54e0b1d6558" }, "downloads": -1, "filename": "whitening-0.1.tar.gz", "has_sig": false, "md5_digest": "84a61e1b2e110c538394fd300dec11d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4670, "upload_time": "2019-09-16T13:31:44", "url": "https://files.pythonhosted.org/packages/4c/3f/6a947be7c37a01c92b7280554b5c42d5bf32a8b2ffee213665fbdc5caffe/whitening-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0867d3ba4b41ca3fca3ca378c92b83af", "sha256": "cc061d7a936d43fca47a4bbf53ca221e00ca911c00623b46ac048183e4444947" }, "downloads": -1, "filename": "whitening-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0867d3ba4b41ca3fca3ca378c92b83af", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5452, "upload_time": "2019-09-16T13:31:42", "url": "https://files.pythonhosted.org/packages/66/c0/7f4d2e677a6a5decde2b199a3fb85f679ac0291b2eb6e12465c7bf96b222/whitening-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "84a61e1b2e110c538394fd300dec11d4", "sha256": "afa89e2281b59741b17c22a25e7a0badcaf39e16130b97543ae0b54e0b1d6558" }, "downloads": -1, "filename": "whitening-0.1.tar.gz", "has_sig": false, "md5_digest": "84a61e1b2e110c538394fd300dec11d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4670, "upload_time": "2019-09-16T13:31:44", "url": "https://files.pythonhosted.org/packages/4c/3f/6a947be7c37a01c92b7280554b5c42d5bf32a8b2ffee213665fbdc5caffe/whitening-0.1.tar.gz" } ] }