-
-
Notifications
You must be signed in to change notification settings - Fork 46
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 new Augmentation - Text Strikethrough #63
Comments
I think this is a pretty interesting idea, and probably has a similar approach to how we'd solve the redaction effect mentioned here in Issue #43. The hardest part would be identifying regions of text to add the For maximum realism, when we find two such edge points in the image, we can check y-values above and below to find the top and bottom of the characters, then average these values to find the middle of the character. We could draw the line connecting the midpoints, like someone would in person. There are some straightforward algorithms for generating the drawn line (e.g. advance five pixels in the x-direction and randomly +1 or -1 in the y-direction), and we could continue it past the endpoints to be even more realistic. |
This technique to find contours may help identify where the text is located. From my experience with this, it can be hit or miss. But, it should work decently well for Augraphy's purpose. Stack Overflow: Finding contours with lines of text in OpenCV |
Yes, was thinking same and I also have experience with this kind of work, So won't take long to add this. |
I have started doing some experiments on this, Its not fully optimized yet.
Will try to implement this one too. |
This looks really nice! I'm curious if the effect works well with the same techniques used in the PencilScribbles augmentation. We might need to pull that pencil effect out into a shared lib as I sense we might use it in more than one place. |
This looks great, and I agree it'd look even better with PencilScribbles generating the strikethrough line. I'm definitely in favor of pulling that code out into |
I have applied the chaikin's algorithm for smoothing the effect of Text Strikethrough. It now looks more realistic to me. Kindly have a look and provide feedback https://colab.research.google.com/drive/11-_ne7ZJuqH8mkcmtM6WrwWGgD0v3VEt?usp=sharing |
This looks quite amazing! I think we’re ready to see the addition of the pencil effect used in PencilScribbles. Is that effect pulled out into a shared lib yet? It might be helpful to add antialiasing beforehand, but I’m not sure (via CV_AA). See example on stackoverflow. |
Merged #86 |
I came across this underline example, and it made me think that perhaps we could adapt code from Strikethrough to create an Underline augmentation. Eventually, even a Highlight augmentation could evolve from this code. Any thoughts on the best way to share that code between augmentations? Is there a generalization of the approach that could be extracted into the shared library functions? |
Exactly, Yesterday I was also going through Memos and Report looking for sample documents containing text strikethrough and came across multiple samples where underlining was intensively used. I think I can make the code generic to cater this underline effect |
Or maybe a flag to insert the line at the center of the text or under the text? |
Does this work with different font sizes? If we pick a standard width
I can see good reasons to do either of these. |
Yes it does.
I guess for end-users we should create a |
Is it necessary to blur the image when making the strikethrough lines? https://github.com/shaheryar1/augraphy/blob/dev/augraphy/augmentations/strikethrough.py#L72 Does this help with contour detection? |
I removed the blur in testing and it doesn't seem to affect the number or placement of the resulting contours. Unless you think we should keep it in, I'm going to remove the blur from this augmentation so the Strikethrough only draws lines on text, without blurring the original image. |
Yes it helps when words spacing is relatively large. I noticed that it is blurring the original image rather than making a copy of it and applying blur operation on that. I'll fix this in my next PR. |
Can we blur a copy of the image to detect the contours, then use the contours to draw lines on a copy without blur? Otherwise this augmentation is really Blur + Strikethrough 😕 |
Yes this is exactly what it is supposed to do. But I guess, In the currently deployed code I forgot to make a copy of image |
Just noticed this in some Report oriented documents, right now we cannot achieve this with current pipeline. Maybe we can add this kind of augmentation in augraphy to support hand cut lines feature. What you guys think about it ?
The text was updated successfully, but these errors were encountered: