Extract sunken parts from an image in hieroglyphs

I'm currently trying to extract hieroglyphic characters from images like this. enter image description here

What I did is used to convert, to find lines and to divide the image in parts to make it easier for me. But I tried a set of algorithms for extracting sunken letters from the image, and I hit a dead end.

What I tried is a mixture of morphological operations and edge detection and contour finding. So, are there any algorithms designed for something like this, or any hint would be appreciated.

+5
source share
4 answers

You can view a sample image, apply some anti-aliasing and find the Otsu threshold, then use this threshold to find the Canny edge with different window sizes.

For a larger window ( 5 x 5 ) you get a noisy image that contains almost all the edges you need, plus noise. noisy

For a smaller window ( 3 x 3 ) you get a less noisy image, but some of the edges are missing. less noisy

If this less noisy image is not good enough, you can try to morphologically restore it using a noisy image as a mask. Here I connected some diagonal edge segments in a noisy image using the morphological transform of misses, and then applied the reconstruction. recon

Using

 Mat k = (Mat_<int>(3, 3) << 0, 0, 1, 0, -1, 0, 1, 0, 0); 

to bind broken ribs, you get a finer outline.

finer outline

Note that in the c++ code below, I used naive reconstruction.

 Mat im = imread("rsSUY.png", 0); /* up sample and smooth */ pyrUp(im, im); GaussianBlur(im, im, Size(5, 5), 5); /* find the Otsu threshold */ Mat bw1, bw2; double th = threshold(im, bw1, 0, 255, THRESH_BINARY | THRESH_OTSU); /* use the found Otsu threshold for Canny */ Canny(im, bw1, th, th/2, 5, true); /* this result would be noisy */ Canny(im, bw2, th, th/2, 3, true); /* this result would be less noisy */ /* link broken edges in more noisy image using hit-miss transform */ Mat k = (Mat_<int>(3, 3) << 0, 0, 1, 0, -1, 0, 0, 0, 0); Mat hitmiss; morphologyEx(bw1, hitmiss, MORPH_HITMISS, k); bw1 |= hitmiss; /* apply morphological reconstruction to less noisy image using the modified noisy image */ Mat kernel = getStructuringElement(MORPH_ELLIPSE, Size(3, 3)); double prevMu = 0; Mat recons = bw2.clone(); for (int i = 0; i < 200; i++) { dilate(recons, recons, kernel); recons &= bw1; Scalar mu = mean(recons); if (abs(mu.val[0] - prevMu) < 0.001) { break; } prevMu = mu.val[0]; } imshow("less noisy", bw2); imshow("reconstructed", recons); waitKey(); 
+4
source

The best solution for this task is machine learning. You can:

  • Trim or mark multiple patterns for each letter
  • SSD train (singly charged multi-band detector) using these samples

The advantage is that you can detect all the letters in the image in one go.

0
source

I have a fairly simple but not very perfect solution.

1. Search for the optimal upper and lower threshold based on the median of the green channel of the image

Upper Threshold Image:

enter image description here

Lower Threshold Image:

enter image description here

2. Subtraction of two images followed by median filtering:

enter image description here

3. Cannon edge detection:

enter image description here

To get the best result, you need to perform some morphological operations.

0
source

I need to extract hieroglyphs from the image ... How ?? thanks

0
source

Source: https://habr.com/ru/post/1270207/


All Articles