0

I have an image like below, I need to extract the text, I'll need to use CNN to do the job. But before that, I need to pre-process it to remove those random thin lines across the entire image.

I'm new to computer vision, I'm considering to use opencv, imagemagick. Currently I have no idea how to remove those lines without damage the text information too much. which morphology should I use? Or maybe use hough line transformation to detect those lines and remove them?

Please help point me the direction. Thanks!

enter image description here

Aaron Shen
  • 8,124
  • 10
  • 44
  • 86
  • Extracting random lines from image is a very hard task and far too broad for an answer. Vertical ones though wouldn't be an issue - you can see [this tutorial](https://docs.opencv.org/3.2.0/d1/dee/tutorial_moprh_lines_detection.html) for explanation. Also take a look at [this question](https://stackoverflow.com/questions/48327567/removing-horizontal-underlines) for some ideas – Dmitrii Z. Feb 01 '18 at 00:09
  • 2
    Helping spammers to accomplish their job is not the main focus of StackOverflow – Costantino Grana Feb 01 '18 at 00:40
  • I, too, do not think it is a good idea to help break captchas. No one here can verify your purpose in doing such and it could be for nefarious purposes – fmw42 Feb 02 '18 at 02:33
  • 1
    How narrow minded! How do you know I'm trying to break captchas. I'm just learning image processing technologies. Removing thin lines can be applied to other business needs!! – Aaron Shen Feb 02 '18 at 03:07
  • 1
    Just by looking at the image I attached, you judge what I'm doing. Question is just question. If it's a valid question, then you shouldn't down vote by your personal preferences. I don't think up/down vote question with your personal feeling is helpful to stackOverflow. Open your mind. – Aaron Shen Feb 02 '18 at 03:10

1 Answers1

3

Just to help next one, to remove thin lines which only have 1 or 2 pixels(you need to first convert image into black and white image, white as foreground, black as background), use Thinning morphology and Ridges kernel shape:

convert xxx.png -colorspace gray -separate -average -threshold 90% -negate -morphology Thinning "Ridges" yyy.png  

refer to the wonderful document here: http://www.imagemagick.org/Usage/morphology

Aaron Shen
  • 8,124
  • 10
  • 44
  • 86