augraphy
augraphy copied to clipboard
I want to mimic artifacts in RVL-CDIP dcoument images
Thank you authors of this package. It is very relevant to my undergraduate research project.
I have clean document images scraped from the Internet such as the following which I would like to preprocess so that they would look similar to images from RVL-CDIP which is a dataset of scanned hardcopy documents. I would like to borrow your experience and ask for your suggestions to go about this. I have experimented with BadPhotoCopy but the parameters currently don't allow much adjusting and the words always seem to get darkened out whereas the words in rvlcdip's scanned images still look clear and legible.
scraped pdf document image example:
rvlcdip's scanned hardcopy document example
^from rvlcdip website
Yours Sincerely, Gordon University of Michigan, Class of 2025
You can combine multiple augmentations to re-create a category of documents. Take the example of invoice above, it can be recreated using pencil scribbles, page borders and page borders.
Thank you authors of this package. It is very relevant to my undergraduate research project.
I have clean document images scraped from the Internet such as the following which I would like to preprocess so that they would look similar to images from RVL-CDIP which is a dataset of scanned hardcopy documents. I would like to borrow your experience and ask for your suggestions to go about this. I have experimented with BadPhotoCopy but the parameters currently don't allow much adjusting and the words always seem to get darkened out whereas the words in rvlcdip's scanned images still look clear and legible.
Yours Sincerely, Gordon University of Michigan, Class of 2025
Hi Gordon,
You would need to combine several augmentations to create a more realistic effect, for example:
And here's the sample code:
from badphotocopy import BadPhotoCopy
from faxify import Faxify
from markup import Markup
from inkbleed import InkBleed
from folding import Folding
import cv2
from matplotlib import pyplot as plt
# read image
img = cv2.imread("img_test.png")
# create augmentation objects
inkbleed = InkBleed()
faxify = Faxify(monochrome=1)
folding = Folding()
markup = Markup(markup_type="strikethrough",markup_thickness_range=(4, 6))
badphotocopy = BadPhotoCopy(noise_type=2, noise_sparsity=(0.5,0.5), noise_concentration=(0.2,0.3))
# applies augmentations
img_output = badphotocopy(inkbleed(folding(faxify(markup(img)))))
# plot output
plt.figure()
plt.imshow(img)
plt.title("input image")
plt.figure()
plt.imshow(img_output, cmap="gray")
plt.title("augmented image")
Please let me know if you have any other related questions.
@kwcckw Currently badphotocopy doesn't have the same params as in 5.0.0. When will the update be released? Did you just git clone the entire dev branch repo?
@gordon-lim Good question. We've had a lot of changes since 5.0.0, maybe it's time to cut a new release. Let me take a look. (Also, check your email)
As for day-to-day use, the library is stable enough to use from the dev branch, so cloning that and importing the module files directly is also an option.
@kwcckw Currently badphotocopy doesn't have the same params as in 5.0.0. When will the update be released? Did you just git clone the entire dev branch repo?
Yes, you may git clone the whole repo, because there will be updates from time to time so i think cloning the repo is a better way for now.
Also please let us know any area of improvement after you try out the library, that will be very helpful for us to further improve the usage experience.