1

I have a bunch of low quality, low contrast (usually also bad light) photos of writings on rocks. I would like my program to detect letter shapes (which are usually quite worn). Since I'm a newbie, I tried applying sobel / laplacian / canny filters, but photos clearly need some preprocessing. Could you please suggest what I could do to get better results. I tried searching online but the solutions I found either don't work or sound like magic to me.

Photo

Duck Dodgers
  • 3,409
  • 8
  • 29
  • 43
Karolina
  • 11
  • 3
  • With known filtering techniques, I am afraid that this task is virtually impossible. The scribings are really faint at places, and there are many perturbing elements (holes, scratches, cracks, random lighting...). Even an untrained human would fail to produce exploitable results. –  Jan 21 '19 at 22:21
  • I work on tasks rather like this using RTI imaging http://culturalheritageimaging.org/Technologies/RTI/ see eg. https://www.youtube.com/watch?v=Hw3rbYvN0h8 I realize of course that this is no direct help to you, unfortunately. – jcupitt Jan 22 '19 at 11:53
  • @Karolina As others suggested, your detections will only be as good as your data is. You can try a few image processing techniques ([example here](https://stackoverflow.com/questions/35276538/advise-filters-to-improve-text-visibility-on-photo/35281770#35281770)), but you won't get very far for "bleached"/overexposed areas and it feels tricky to automate. I would also try manually tracing the letters as best as your vision allows you to (and maybe think of what image features allowed you to trace the characters) ? – George Profenza Jan 22 '19 at 13:04

1 Answers1

-1

This problem requires a complete algorithm. Short of writing a complete code in MATLAB/Octave or Python/C++ using OpenCV, here are my two cents on how maybe I would go about this.

  1. The text in that image is edged/carved into the rock. I would look to first enhance the contrast of the image, through some sort of histogram equalization. This should make the text a bit more prominent. (Hint: check out calcHist() and equalizeHist() in opencv, or imhist() and adapthisteq() in MATLAB.)

  2. I would go about removing the unnecessary parts of the image.

    1. Remove all that is not the rock.

      1. For this one would remove everything which is not the rock. That means, removing the part of the image near the top, which is darker mostly. You could do a black&white thresholding on the image and then apply the Hough-Transform to detect the largest horizontal line or nearly horizontal line in the image.
      2. In a similar fashion, I would try to detect the the rock edge at 45°.
      3. Remove everything above those two lines, by using binary masking.
      4. This should leave you with a cropped image, something close to this. (Hint: See cv2.HoughLines as explained here or houghlines on Matlab as explained here. )

        To elaborate this is what I mean, enter image description here

    2. Next, I would remove those sharp edges around the bottom right corner of the rock. This could be done in my view in one of two ways.

      • Those edges look very fine and sharp. That means, high frequency components. Actually, those appear to be the highest frequency components in the whole image. So either you take the fft() function from MATLAB or the cv2.idft from opencv and transform the image into the frequency domain and remove all frequency components above a certain frequency threshold. (What that threshold is, I cannot say. One has to test and see. Be careful not to set the threshold too low or you could lose the sharpness of your text also.). Transform back the modified image back from the frequency domain.
      • Alternatively, and more simply, you could blur the image using imgausfilt from MATLAB or cv2.filter2D from opencv. The size of the filter/kernel used with those functions matters. Too big and you lose too much detail.
      • This should smooth out those sharp edges at the bottom. (Note: the image is just for illustration purposes. The smoothing will of course effect the entire image. Therefore best to keep the smoothing down to only as much as to remove those fine edges, so they don't come up during the edge-detection step.)enter image description here
  3. Now with large parts of the 'uninteresting' sections of the image removed, you could apply some edge detection algorithm, (e.g. Canny, as you mentioned yourself) on your thresholded black&white image and hopefully you should have more of the text. Equivalent functions for edge detection exist in both OpenCV and MATLAB.

TODO: Of course, the little circles in between the text are still a problem and the algorithm could be refined (for example to match shapes such as circles and then) remove them also. Also, how to reconstruct the damaged portions of the text from this image, is probably a bit more challenging (at least for me).

  1. Finally, you could use some OCR recognition, for example with tesseract and OpenCV, you could try to extract the text from the processed image.
Duck Dodgers
  • 3,409
  • 8
  • 29
  • 43