sparkfish / augraphy

Augmentation pipeline for rendering synthetic paper printing, faxing, scanning and copy machine processes
https://github.com/sparkfish/augraphy
MIT License
351 stars 46 forks source link

Add Pattern-based Distortion Generator #242

Closed jboarman closed 1 year ago

jboarman commented 1 year ago

Printed documents often include artifacts that may come from the paper textures, printing presses, etc.

The geopatterns python port offers a potential avenue for generating such patterns that could be processed a bit and merged into the paper layer. Brandon Mills offers a web-based demo of geopatterns.

Below is an illustrative example that comes from the Tai Le Historical Document Image Binarization Dataset 2021: image

jboarman commented 1 year ago

Voronoi and Delaunay tessellation offer another method to generate patterns that could be sampled and applied for generating distortions. This is particularly appealing since there are readily available python implementations that could be more quickly leveraged:

Voronoi Tessellation image

Delaunay Tessellation image

Voronoi vs Delaunay Tessellation image

Additionally, colorized implementations can be generated based on a source image where the color of each shape is determined by the average color of each corner and the center of the polygon^1. Further, this may serve as a potential shortcut for implementing wrinkled paper.

image

jboarman commented 1 year ago

Related concept, using aperiodic tiling

An aperiodic monotile David Smith, Joseph Samuel Myers, Craig S. Kaplan, and Chaim Goodman-Strauss, 2023

An aperiodic monotile, sometimes called an "einstein", is a shape that tiles the plane, but never periodically. In this paper we present the first true aperiodic monotile, a shape that forces aperiodicity through geometry alone, with no additional constraints applied via matching conditions. We prove that this shape, a polykite that we call "the hat", must assemble into tilings based on a substitution system. The drawing above shows a patch of hats produced using a few rounds of substitution.

This page collects the resources associated with this work. We invite you to look at all of the following. https://cs.uwaterloo.ca/~csk/hat/

image

jboarman commented 1 year ago

Organic Patterns

This "pattern" is more organic and random-looking, but still consistent enough to think of it as a pattern. In this case, the pattern would be combined with a deboss function (see #164) when rendered to the paper layer. image

Use of Skeletonize Function

These organic patterns show the use of the skeletonize function which might be useful when applied to noise to generate organic-looking patterns: image

Perlin Noise as Probability Function

Using Perlin noise (see background of this image) could also be used as a probability function for placement of shapes on a layer: image

jboarman commented 1 year ago

While subconsciously searching for what a "pattern" even means, I noticed this paper from a mailed envelope containing tax information intended to obscure its contents.

Wikepedia has some notes on patterns from nature that also reflect on these ideas.

So far, I think patterns have the following characteristics:

image

jboarman commented 1 year ago

Errors in Perlin Noise Makes Interesting Patterns

https://stackoverflow.com/questions/26611906/strange-result-from-perlin-noise-generator image image

jboarman commented 1 year ago

This repo some experiments with "plane-filling curves" and Fourier transforms that are interesting for considering future types of patterns.

There's more details on a number of space-filling curve techniques on wikipedia.

image