1

I have several images which show bubbles in water. The task is to identify these bubbles, to count and measure them.

image of the bubbles

I know this is not easy. 100% accuracy is not needed. The best I have so far is the following:

RidgeFilterV2[img_, \[Sigma]_: 1] := Module[
  {data = ImageData[img], Lxx, Lxy, Lyy},
  {Lxx, Lxy, Lyy} = 
   DerivativeFilter[data, {{0, 2}, {1, 1}, {2, 0}}, \[Sigma]];
  Image[
   Chop[\[Sigma]^(3/2)/2 (Sqrt[(Lxx - Lyy)^2 + 4 Lxy^2] - Lxx - Lyy)]
   ]
  ]

TestImage = Import["https://i.imgur.com/pWJAdWv.png"];
ImageTransform[1] = ImageAdjust[TestImage];
ImageTransform[2] = RidgeFilterV2[ImageTransform[1], 3];
ImageTransform[3] = Binarize[ImageTransform[2], 0.008];
ImageTransform[4] = SelectComponents[
   ImageTransform[3], {"Circularity", "Area", 
    "Elongation"}, #1 > 0.3 && #2 > 9 && #3 < 0.7 &];

Visualizing the result:

ImageMultiply[
 Colorize[MorphologicalComponents[ImageTransform[4]]], TestImage]

As you can see there are two problems:
- Some of the bubbles get lost completely.
- Many bubbles which are not connected in reality are identifed as one single object.

I would appreciate any hints/ideas to improve my algorithm.

RMMA
  • 2,710
  • 2
  • 18
  • 33
  • There are some excellent examples on this forum of image processing. Here's one recently: https://mathematica.stackexchange.com/questions/208714/find-gridlines-in-image-of-blots-arranged-in-a-grid – Dominic Dec 09 '19 at 10:04
  • @Dominic Thanks. I appreciate the forum as an excellent source of examples. Already tried to adopt several approaches to tackle the Problem. Still I think there is some room for improvement. Just wanted to know if there are any fresh ideas on that Problem. – RMMA Dec 09 '19 at 11:35
  • Maybe you can read this https://www.zhihu.com/question/27834147/answer/207262440 – AsukaMinato Dec 09 '19 at 16:11

0 Answers0