Ask Your Question
0

Segment the "cupules" of a prehistoric engraving.

asked 2019-06-26 08:33:41 -0600

SylvainArd gravatar image

updated 2019-06-26 09:39:40 -0600

berak gravatar image

Hi all, recently I had to detect and measure the holes of a prehistoric engraving called in French "cupules", these are holes done by prehistoric men larger than holes called "négatifs d'éclats". This is an explanatory diagram : and this is an image to treat : These images are of poor quality, I know, but they are those sended by the archaeologist. There are 7 cupules on the image. I tried to do an Otsu binarization and then to slip a complicated mask formed by circles and segments which must be even white or black and verify on each pixel of the image if the mask match a "cupule", but it doesn't work, it is not the good method. If you have a better method I will be happy. Thank you very much Best regards

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2019-06-27 08:10:18 -0600

VxW gravatar image

Hi,

you can try some simple preprocessing techniques, before thresholding, but these depends mostly on the images you have.

I did the following: 1) image resizing (fx=0.3, fy=0.3) 2) convert to grayscale 3) apply median filter (kernelsize=9) 4) Ostsu filtering

The result is than: image description

on this you can apply a simple blob detection

Best

edit flag offensive delete link more

Comments

The problem is, that Otsu do not select the optimal threshold in this case. I would suggest to try out different auto threshold techniques. A auto threhsold which will work for this image is from Li, but which is not in OpenCV. If you have Python, try this out:

src = cv2.imread('DSCF4019.jpg',1)

resize = cv2.resize(src, (0,0), fx=0.3, fy=0.3)
src_gray = cv2.cvtColor(resize, cv2.COLOR_BGR2GRAY)
median_im = cv2.medianBlur(src_gray, 15)
thresh = filters.threshold_li(median_im)
im_thresh = median_im > thresh
binary_im = np.array(im_thresh*255).astype(np.uint8)

cv2.imshow('binary_im', binary_im)
cv2.waitKey()
VxW gravatar imageVxW ( 2019-07-01 06:19:28 -0600 )edit
0

answered 2019-06-29 05:47:25 -0600

SylvainArd gravatar image

updated 2019-06-29 05:48:38 -0600

Hello, I have tested your solution by this code :

Mat src;
if (argc > 1)
{
    cout << "image : " << argv[1] << endl;
    src = imread(argv[1], 1);//read the image in parameter
}
else
    src = imread(appDir + "\\image.jpg",1);
Mat src_gray, binary, blurred;
cv::imwrite(appDir + "\\color.jpg", src);
Mat resized;
resize(src, resized, Size(0,0), 0.3, 0.3);
cv::imwrite(appDir + "\\resized.jpg", resized);
cvtColor(resized, src_gray, CV_BGR2GRAY);//converts the image into gray
cv::imwrite(appDir + "\\src_gray.jpg", src_gray);
Mat inverted;
bitwise_not(src_gray, inverted);
medianBlur(inverted, blurred, 9);//blur the image to eliminate noise
cv::imwrite(appDir + "\\blur.jpg", blurred);
threshold(blurred, binary,127, 255, THRESH_BINARY | THRESH_OTSU);
//threshold(blurred, binary, 50, 255, THRESH_BINARY);
cv::imwrite(appDir + "\\binaryOtsu.jpg", binary);

but I get this image : http://sylvain-ard.fr/temp/binaryOtsu... which is very different from yours and not good, can you explain what I forget, I use OpenCV 3.4.6 Thank you Best regards

edit flag offensive delete link more

Comments

not an answer, unfortunately.

berak gravatar imageberak ( 2019-06-30 06:18:28 -0600 )edit

it is an answer for VxW but it appears at its top I dont't know why !

SylvainArd gravatar imageSylvainArd ( 2019-06-30 06:24:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-06-26 08:33:41 -0600

Seen: 326 times

Last updated: Jun 29 '19