sparkfish / augraphy

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

Add Stains Augmentation #153

Closed proofconstruction closed 10 months ago

proofconstruction commented 2 years ago

We should figure out an augmentation for placing stains on a document image, which generates the stains itself.

This probably looks like 2 new functions in augraphy.augmentations.lib:

  1. a function to generate a boundary for the stain
  2. a function to color&darken the interior of the boundary generated by function 1

We can probably use the model here to produce a realistic diffusion effect for function 2.

proofconstruction commented 2 years ago

To generate a boundary, we can choose a pixel in the image and make several particles {p1, p2, ..., pn} randomly walk starting at that pixel, for some number of cycles. The resulting points {p1_final, p2_final, ..., pn_final} will lie on the boundary. The Graham scan algorithm can then be used to generate the convex hull enclosing those points, which we can then smooth by drawing Bezier curves or cubic splines through the hull points.

kwcckw commented 2 years ago

I was testing on the effect earlier and was able to generate something like this:

image

Will something like this useful?

Actually I couldn't access the full paper above, so couldn't get much info from it.

kwcckw commented 10 months ago

This is now added in this pull request: https://github.com/sparkfish/augraphy/pull/422