Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stains Augmentation #153

Closed
proofconstruction opened this issue Feb 2, 2022 · 3 comments · Fixed by #422
Closed

Add Stains Augmentation #153

proofconstruction opened this issue Feb 2, 2022 · 3 comments · Fixed by #422
Labels
enhancement New feature or request experimental Functionality that may be too risky to develop or release

Comments

@proofconstruction
Copy link
Contributor

proofconstruction commented Feb 2, 2022

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
Copy link
Contributor Author

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
Copy link
Collaborator

kwcckw commented Feb 4, 2022

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.

@jboarman jboarman added the enhancement New feature or request label Jan 14, 2023
@jboarman jboarman added the experimental Functionality that may be too risky to develop or release label Mar 11, 2023
@jboarman jboarman changed the title Add stain augmentation Add Stains Augmentation Mar 18, 2023
@kwcckw kwcckw linked a pull request Dec 29, 2023 that will close this issue
@kwcckw
Copy link
Collaborator

kwcckw commented Dec 29, 2023

This is now added in this pull request:
#422

@kwcckw kwcckw closed this as completed Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request experimental Functionality that may be too risky to develop or release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants