opencv - Extraction of sunken portions from image in hieroglyphics -
currently trying extract hieroglyphics symbols images one.
what have done used hough transform find lines , split image in portions make easier me. tried set of algorithms extract sunken letters image , hit dead end..
what have tried mixture of morphological operations , edge detection , contour finding. there algorithms devised or hint appreciated.
you can up-sample input image, apply smoothing, , find otsu threshold, use threshold find canny edges different window sizes.
for larger window (5 x 5
), noisy image contains edges need, plus noise.
for smaller window (3 x 3
), less noisy image, of edges missing.
if less noisy image not enough, can try morphologically reconstructing using noisy image mask. here, i've linked diagonal edge segments in noisy image using morphological hit-miss transform , applied reconstruction.
using
mat k = (mat_<int>(3, 3) << 0, 0, 1, 0, -1, 0, 1, 0, 0);
kernel linking broken edges, thinner outline.
please note in c++
code below, i've used naive reconstruction.
mat im = imread("rssuy.png", 0); /* sample , smooth */ pyrup(im, im); gaussianblur(im, im, size(5, 5), 5); /* find otsu threshold */ mat bw1, bw2; double th = threshold(im, bw1, 0, 255, thresh_binary | thresh_otsu); /* use found otsu threshold canny */ canny(im, bw1, th, th/2, 5, true); /* result noisy */ canny(im, bw2, th, th/2, 3, true); /* result 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 less noisy image using modified noisy image */ mat kernel = getstructuringelement(morph_ellipse, size(3, 3)); double prevmu = 0; mat recons = bw2.clone(); (int = 0; < 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();
Comments
Post a Comment