Page 1 of 1

Horizontal and Vertical Line Removal

Posted: 2010-03-02T12:17:11-07:00
by MkumarD
Dear Guys,

First of all I need to thank everyone who contributes their knowledge to develop this awesome package ImageMagick.

I'm new to image handling and am currently developing an Image based DataEntry application, In this process I need to remove all the Horizontal lines and vertial(some cases) lines from the Tiff Image. Am using ImageMagick to manipulate images and this is really good.

Is their any method in ImageMagick to remove the lines from Image File?

Any suggestions would be appreciated.

Thanks in advance
Muthukumar D

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-02T12:25:01-07:00
by magick
See http://www.imagemagick.org/Usage/morphology/. A thinning algorithm may work for this problem.

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-02T12:41:58-07:00
by MkumarD
Thanks for the response, I will go through this.

Meanwhile could you please give an example for this.

Thanks
Muthukumar D

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-02T14:47:38-07:00
by fmw42
it would be best for you to provide a link to one of your images, so we can see the exact nature of the problem and then describe what you would like removed or what you want preserved.

Here is a simple example of the morphologic filter called hit or miss, which Anthony will be building into his -morphology function that is under development now.

lines at various directions:

Image

v=0.333333
convert lines.gif -convolve "0,$v,0,0,$v,0,0,$v,0" -threshold 99% lines_vertical.gif

Image

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-17T05:28:37-07:00
by Evadido
Hi,

I'm looking too for a way to remove lines from images, as a step for preprocessing it for ocr. I tried the command you supplied with several bw images (inverting colors and so), and it seems to do nothing: no error, and the resulting image is the same as the original.

Is there another way to try it?

Thanks in advance

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-17T05:49:53-07:00
by Bonzo
What version of Im are you using, how are you running the command, can you provide an image ?

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-17T09:22:04-07:00
by fmw42
-convolve was broken for a few releases between about 6.5.9.5 and 6.6.0.3. I believe it was fixed in 6.6.0.4 and definitely by 6.6.0.5

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-17T09:55:27-07:00
by Evadido
I'm running version 6.5.1-0 over Ubuntu. It is not in the range it was broken.

I just copied & pasted the two command lines changing the file names.

An example image (original and inverted):

http://protalia.com/prueba.pnm
http://protalia.com/prueba2.pnm

Thank you a lot

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-17T10:28:24-07:00
by fmw42
Two reasons my technique above with -convolve does not work is 1) your lines are not perfectly vertical and MORE IMPORTANT 2) your lines are thicker than 1 pixel wide, which was the assumption of the convolution kernel provided above for my example.

Unfortunately, I am not sure what you can do to remove those lines.

You can try -lat and choose a filter size smaller than the thickness of the lines you want to remove, but larger than the text you want to preserve. My textcleaner will do that with the proper choice of filter size as it uses -lat. NOTE the larger the filter, the slower it will run.

But I would suggest you play with a smaller subsection of your image as your image is huge at 5000x6000 pixels.

Re: Horizontal and Vertical Line Removal

Posted: 2010-03-17T11:12:05-07:00
by Evadido
Ok, I'll try that, thanks a lot

Re: Horizontal and Vertical Line Removal

Posted: 2014-08-16T23:43:50-07:00
by abcdef
Can you please provide the matrix options to remove horizontal and vertical lines which are not clear. I could try matrix like 0,1,0 0,1,0 0,1,0 and found that some shades of the lines are removed.. but not significant. I tried 5x5 as well. Please suggest. The lines are more than 1pixel and width is not same at all places of the line.

Re: Horizontal and Vertical Line Removal

Posted: 2014-08-17T04:52:25-07:00
by snibgo
You should start a new thread with your problem. Explain what you are trying to do. Provide a sample image (you can upload to somewhere like dropbox.com and paste the link here). Tell us what version of IM you are using, on what platform.

Re: Horizontal and Vertical Line Removal

Posted: 2017-10-03T07:01:28-07:00
by vista123
Equivalent c# code?

Re: Horizontal and Vertical Line Removal

Posted: 2017-10-03T15:21:27-07:00
by fmw42
vista123 wrote: 2017-10-03T07:01:28-07:00 Equivalent c# code?
Equivalent code to exactly what? Please always be specific. Provide your IM version and platform and an example of input and output and some command line.