augraphy icon indicating copy to clipboard operation
augraphy copied to clipboard

Add Emboss / Deboss Stamp Augmentation (or Option)

Open jboarman opened this issue 3 years ago • 2 comments

Add 3D effect of raised (embossed) and lowered (debossed) text or symbols that you might see on a seal or a business card. We may need this as an internal shared lib in addition to being a top-level augmentation since we might want to raise/lower text overall or perhaps just a single seal when add in notary seals as an augmentation type of its own.

image image

image image

image image

jboarman avatar Mar 10 '22 20:03 jboarman

This should be possible by adding certain level of gradient in the edges of the outline, but in actual use case, i think we need to get some templates of those seals? Otherwise it might not be easy to create those seals from scratch.

kwcckw avatar Apr 12 '22 13:04 kwcckw

We have a draft set of stamps that could be integrated for use with this proposed augmentation, but that will need to be packaged for download separately, possibly on zonodo. Nevertheless, a user will need to reference a set of images within a folder, or possibly an existing set that we may offer via URL to download via zonodo or figshare, etc.

Filters and Post-Processing

Below are possible filters that may be useful to create a debossed or embossed representation of the stamp that could then be colorized and blended into the ink layer.

The use of course-grained noise would help make the impression look more natural when blended with the page. We may also want to borrow some of the letterpress functionality to blend ink-based stamps as well.

Note that colorized stamps would represent ink-pressed stamps while a semi-transparent white(?) stamp would represent an impression pressed into the paper to raise/low the paper instead of being combined with ink. Both stamps and seal can have the embossed or debossed impression effect. So a color and alpha transparency level associated with color could be passed in as a parameter or randomized (see markup augmentation and overlaybuilder utility for reference implementations).

Both scipy or opencv are dependencies that offer the convolutions. We may want to compare speeds, but if it's a toss-up then we should stick with opencv for consistency with the majority of our existing code:

opencv: debossed_image = cv2.filter2D(img, -1, kernel_deboss, borderType=cv2.BORDER_REFLECT)

scipi: embossed_image = convolve2d(image, kernel_emboss, mode='same', boundary='symm')

Deboss filters

# Deboss filter kernel variation 1
kernel_deboss_1 = np.array([[-1, -1, -1],
                            [-1, 9, -1],
                            [-1, -1, -1]])

# Deboss filter kernel variation 2
kernel_deboss_2 = np.array([[0, -2, -2],
                            [2, 0, -2],
                            [2, 2, 0]])

# Deboss filter kernel variation 3
kernel_deboss_3 = np.array([[-1, -2, -1],
                            [-2, 12, -2],
                            [-1, -2, -1]])

Emboss filters

# Emboss filter kernel variation 1
kernel_emboss_1 = np.array([[-1, -1, 0],
                            [-1, 0, 1],
                            [0, 1, 1]])

# Emboss filter kernel variation 2
kernel_emboss_2 = np.array([[0, 1, 0],
                            [1, -4, 1],
                            [0, 1, 0]])

# Emboss filter kernel variation 3
kernel_emboss_3 = np.array([[-2, -1, 0],
                            [-1, 0, 1],
                            [0, 1, 2]])

jboarman avatar Apr 02 '23 18:04 jboarman