Message Boards Message Boards


Extracting digits from the image a hydrometer dashboard

Posted 9 years ago
7 Replies
7 Total Likes
Hi !

I am trying to pick the numbers that an hydrometer shows, but the images generally are blurry and not so perfect...
I intend to have  a monthly data set of the water consuption, automactly done through an mathematica code.

So I have 2 challenges: 

1 - cleaning (using filters) the pics
2- taking just the numbers that are shown through the metering reading.

Any suggestion?

I use an very cheap smartphone, 5 megapixels of resolution.
(how  can I attached images here??)
7 Replies
For pasting images into posts, please see this guide. For improving images you could start from basic functions like Sharpen and ImageAdjust. If more sophisticated filters are needed you may want to take look at the guides and examples in Image Processing & Analysis . 
Hi Vitaly, I have been testing the filters. And also I read the tutorials and guides. But I am litlle confuse to use morphological imaging to pick the numbers. I am attaching the image.

And now what I got after some tries. How to isolate the numbers?

I used the following code:
i= image....

table = Transpose@
   {{"Gaussian", GaussianFilter[i, 5]},
    {"bilateral", BilateralFilter[i, 5, .1]},
    {"gradient", GradientFilter[i, 5] // ImageAdjust},
    {"Gabor", GaborFilter[i, 5, {1, 1}] // ImageAdjust}};
Row[MapThread[Panel[#2, #1, ImageSize -> 200] &, table]]
So I can choose the best Image X filtering

And the then It seems to me that
{"Gaussian", GaussianFilter[i, 5]}
It works fine. See te last picture.

But now I want to get the numbers, how ?
Posted 9 years ago
Hello Marcelo,

I am no expert on this area, but how about aquirering an excerpt or "template" of each individual number on the hydrometer (From 0-9)? Therenext supply it to ImageCorrelate[]. Get the result of ImageCorrelate[], Binarize, ColorNegate, and finally supply it to MorphologicalComponents. Using MorphologicalComponenets, it seems you can get the locations using ComponentMeasurements[] (  That shoult at least, if you're lucky and I am correct, give you the position of the numbers. That might make them easier to isolate :-)
Hello Marcelo,

The Wolfram Broadcast
contains a very impressive example where Markus van Almsick demonstrates a method of extracting notes from an image of a musical score.  It is worth watching even if it doesn't solve your problem perfectly. Also, you may be able to utilize the TextRecognize function after a bit more image pre-processing.
Hi folks!

First I´ll try Perdesen´s suggestion.
If the camera doesn't move you could just crop a hand made mask around it and then use TextRecognize[] to read off the numbers themselves.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract