Filling the gaps made in pixels due to line removal

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
wineismine
Posts: 6
Joined: 2017-10-22T04:06:07-07:00
Authentication code: 1151

Filling the gaps made in pixels due to line removal

Post by wineismine »

Recently i saw a topic about line removal using leptonica.http://www.leptonica.org/line-removal.html.So i tried it in imagemagick and i made it till
Figure 9
Image
But i cant figure out the correct command for the Final figure which fills up the mixing pixels only in the image(which is below).So please help me.
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Filling the gaps made in pixels due to line removal

Post by snibgo »

I've written a couple of web pages on the topic, plus code -- search "filling holes" on my web page.

The example on your link uses a morphological open to join lines across the gap. My hole-filling code copies suitable areas from elsewhere in the image. The gap is only 2 or 3 pixels high, so they should work fine. Almost anything could be used, such as a vertical blur.

I've also written a page about joining broken lines, but that's mostly designed for binary images.
snibgo's IM pages: im.snibgo.com
wineismine
Posts: 6
Joined: 2017-10-22T04:06:07-07:00
Authentication code: 1151

Re: Filling the gaps made in pixels due to line removal

Post by wineismine »

where to save the script file fillholespri?
magick: unable to load module `fillholespri' @ error/module.c/InvokeDynamicImageFilter/1663.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Filling the gaps made in pixels due to line removal

Post by fmw42 »

This is not perfect, but try

Unix:

Code: Select all

convert dave-proc8.png \
\( -clone 0 -morphology convolve blur:0x5+90 -level 50x100% \) \
\( -clone 0 -threshold 99% -blur 0x1 \) \
-compose over -composite -level 30x100% \
result.png

Windows:

Code: Select all

convert dave-proc8.png ^
( -clone 0 -morphology convolve blur:0x5+90 -level 50x100% ) ^
( -clone 0 -threshold 99% -blur 0x1 ) ^
-compose over -composite -level 30x100% ^
result.png
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Filling the gaps made in pixels due to line removal

Post by snibgo »

fillholespri.c isn't a script, but C code. Put it in the "filters" directory of your IM source, and re-build IM. Instructions are in Process modules.
snibgo's IM pages: im.snibgo.com
Post Reply