Horizontal and Vertical Line Removal
Horizontal and Vertical Line Removal
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
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
See http://www.imagemagick.org/Usage/morphology/. A thinning algorithm may work for this problem.
Re: Horizontal and Vertical Line Removal
Thanks for the response, I will go through this.
Meanwhile could you please give an example for this.
Thanks
Muthukumar D
Meanwhile could you please give an example for this.
Thanks
Muthukumar D
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Horizontal and Vertical Line Removal
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:
v=0.333333
convert lines.gif -convolve "0,$v,0,0,$v,0,0,$v,0" -threshold 99% lines_vertical.gif
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:
v=0.333333
convert lines.gif -convolve "0,$v,0,0,$v,0,0,$v,0" -threshold 99% lines_vertical.gif
Re: Horizontal and Vertical Line Removal
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
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
What version of Im are you using, how are you running the command, can you provide an image ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Horizontal and Vertical Line Removal
-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
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Horizontal and Vertical Line Removal
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.
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.
Last edited by fmw42 on 2010-03-17T11:47:27-07:00, edited 2 times in total.
Re: Horizontal and Vertical Line Removal
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.
Thanks
Vinod Bapatla
Vinod Bapatla
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Horizontal and Vertical Line Removal
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.
snibgo's IM pages: im.snibgo.com
Re: Horizontal and Vertical Line Removal
Equivalent c# code?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Horizontal and Vertical Line Removal
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.