0

I have images that are noised with some random lines like the following one:

enter image description here

enter image description here

I want to apply on them some preprocessing in order to find the lines (the lines that distort the writing).

I was seen some ways, but it is in Python, not C++:

Remove noisy lines from an image

Remove non straight lines from text image

In C++, I was try but result images:

enter image description here

enter image description here

the result which I want (I do it with Photoshop):

enter image description here

enter image description here

How to find lines in that images in C++ with OpenCV? thanks

Quang
  • 183
  • 2
  • 10
  • 1
    this can't be solved with low-level methods. this can't be cleaned up. this should be solved by using OCR that is tolerant of noise. sadly, all the "modern" OCR I see is stuck in the last century (binarization...) – Christoph Rackwitz Sep 27 '21 at 12:46
  • @ChristophRackwitz it is so sad!... But I needn't to OCR, I just want to find the lines in text images. – Quang Sep 27 '21 at 13:24
  • 1
    ah! then you could try grayscale morphology. use a kernel with a wide but flat shape. 1x9 maybe. the result could look like this: https://imgur.com/ZowE4Lx and that can be improved further – Christoph Rackwitz Sep 27 '21 at 14:36
  • you linked to other answers. some of those use python. they also appear to perform better than simple grayscale morphology. you should look into that. – Christoph Rackwitz Sep 27 '21 at 14:42
  • @ChristophRackwitz yes, thanks! I still get the right values of kernel. – Quang Sep 28 '21 at 02:02

1 Answers1

0

I am not sure about this. Like @Chistoph Racwit said, you might need to use some sort of OCR.

But just to try it out, I think you can apply a horizontal filter that highlights any horizontal line in the image. It might not give the best-looking result but with some clean-up, you could end up with where the lines are in the image.

You can use this image to detect lines' locations and draw them in the original image with red color.

No One
  • 21
  • 6