augraphy icon indicating copy to clipboard operation
augraphy copied to clipboard

Add stain augmentation

Open proofconstruction opened this issue 3 years ago • 2 comments

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 avatar Feb 02 '22 22:02 proofconstruction

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.

proofconstruction avatar Feb 03 '22 00:02 proofconstruction

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 avatar Feb 04 '22 07:02 kwcckw

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

kwcckw avatar Dec 29 '23 07:12 kwcckw