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: 3
Joined: 2017-10-22T04:06:07-07:00
Authentication code: 1151

Filling the gaps made in pixels due to line removal

Post by wineismine » 2017-10-22T04:48:09-07:00

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: 9379
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 » 2017-10-22T05:43:36-07:00

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: 3
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 » 2017-10-22T18:46:15-07:00

where to save the script file fillholespri?
magick: unable to load module `fillholespri' @ error/module.c/InvokeDynamicImageFilter/1663.

User avatar
fmw42
Posts: 22081
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2017-10-22T20:20:36-07:00

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: 9379
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 » 2017-10-22T20:37:27-07:00

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