I came across a paper (https://arxiv.org/pdf/1608.04224.pdf) which uses synthetic handwriting data generated with the ImageMagick convert command, using a lot of different handwriting fonts like the images below.
I am new to using the ImageMagick tool but I was wondering if I can get a tight bounding box for each individual character in each word. I'm not sure how the convert function works, but if it writes each letter separately, it should be possible to get the bounding box after writing the letter right?
Detect bounding box of characters written by convert
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Detect bounding box of characters written by convert
The PDF has error 403 "Forbidden". If you give the title and author, perhaps the paper is available elsewhere.
IM calls a delegate to rasterize text strings. It can do this multiple times to build up a string, which could give the bounding box of each added character. It's a bit messy because glyphs can overlap.
For example, it can rasterize "easil" and then "easily". The difference between these gives the bounding box of the final "y".
IM calls a delegate to rasterize text strings. It can do this multiple times to build up a string, which could give the bounding box of each added character. It's a bit messy because glyphs can overlap.
For example, it can rasterize "easil" and then "easily". The difference between these gives the bounding box of the final "y".
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Detect bounding box of characters written by convert
If each character is separate (does not touch any other character), then you can use -connected-components to get the bounding boxes of each character. If they touch, then it would get the bounding box of all connected characters and not each one separately. See https://imagemagick.org/script/connected-components.php. Once you have the bounding boxes, you can draw boxes around each separate region.
Re: Detect bounding box of characters written by convert
Thanks for the advice, I have solved the problem by generating each letter iteratively and masking the previously generated letters to get the bounding box of the new one with OpenCV. This of course causes a lot of overlap for each bounding box, but that should be fine.
Example output:
Example output: