# stones' detection in jewel image

The project I am doing is to detect stones in an image of a jewel, so as to get the idea of the deduction to be made in the gross weight of the jewel.
I have done image-segmentation in the HSV color space following this paper. If given a raw input like IMAGE1 below, the method I follow is three-fold:

• using "gold" pixels threshold values I detect the gold part in the image (IMAGE2 below)
• then I detect the background/foreground in the image as the background is known to be white (IMAGE3 below)
• intersection of the outputs of the first 2 steps -- not GOLD && FOREGROUND => STONE (IMAGE4 below)

The steps are illustrated in this image: Some sample images and their corresponding results can be found:

Apart from this, I have tried using the flood-fill algorithm to flood the gold / stone pixels based on some pre-known seed points. But due to the non-uniform illumination and the fineness of the image, flood-fill didn't produce good results. Also the lo_diff and up_diff values (in the OpenCV implementation) are not universally fixed and need to be changed for each query point.

I also tried using template matching in it's naive form but the complications of variance of the occurrence of the template in the query image led to that method being not applicable everytime. And if the stone type is irregular, then template matching gives erratic results.

Segmentation in the HSV color space yielded better and more generally applicable results than the previous two methods. But as visible in the results of the 4 sample images previously mentioned, that too has it's own limitations, like

• In the second image, due to poor illumination all of the background is (wrongly) detected as being foreground.
• In the first image, due to (very) slight illumination problem in the left-top corner, the detected area is blown up.
• Similar noisy issues are visible in the last 2 results.

Is there a better way of solving the problem? Can someone suggest some improvements to the current approach?
Suggestions at an altogether new approach are also welcome. Is it possible to implement a machine learning approach to the problem apart from image-processing? Can someone give any specific pointers in that direction?

• Can you post a full-resolution version of the actual image? – Tolga Birdal Sep 10 '17 at 9:15
• @TolgaBirdal - They are linked (imgur links) in the text written as image-1, image-2, image-3 and image-4 with their corresponding results in front of them. I did not post them in the body of the question as it would have increased it's length considerably. – Shraddheya Shendre Sep 10 '17 at 9:47