augraphy icon indicating copy to clipboard operation
augraphy copied to clipboard

I want to mimic artifacts in RVL-CDIP dcoument images

Open gordon-lim opened this issue 2 years ago • 5 comments

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: 03878b0e-e65c-439a-aadc-549d797442f4

rvlcdip's scanned hardcopy document example Screenshot 2021-12-26 at 11 46 28 AM ^from rvlcdip website

Yours Sincerely, Gordon University of Michigan, Class of 2025

gordon-lim avatar Dec 26 '21 16:12 gordon-lim

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.

shaheryar1 avatar Dec 26 '21 18:12 shaheryar1

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:

image

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 avatar Dec 27 '21 11:12 kwcckw

@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 avatar Dec 29 '21 20:12 gordon-lim

@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.

proofconstruction avatar Dec 29 '21 21:12 proofconstruction

@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.

kwcckw avatar Dec 30 '21 01:12 kwcckw