I want to quantify the flow from photos taken from a sensor such as this one:
For a limited number of readings, I can use a plot digitization method. However, I need to do this many times for hundreds of photos to construct the flow as a function of time. The location of the sensor is somewhat challenging, so I can’t use a camera stand either (meaning the position of min and max are probably not constant in time due to hand held recording device). Therefore, I am trying to make this process automated. The location of the top of the ball with respect to the scale is what I am looking for. The approach I have in mind follows, but if anyone can suggest a better approach that would be even more appreciated.
I imported the image and called it
img1. Then I binarized it:
bin = Binarize[img1, 0.3]
Then I negated the image and cleaned it up slightly:
cleanup = DeleteSmallComponents[ColorNegate@bin, 50]
MMA’s text recognition doesn’t seem to be working with these numbers, so I gave up trying to use it. However, after many tests I found
MorphologicalPerimeter quite useful:
Also, I found out these thresholds can isolate the scale:
SelectComponents[cleanup, #Elongation > .4 && #AdjacentBorderCount == 0 &]
and for the ball:
However, now I am stuck. I don’t know how to construct a tangent on top of the ball and determine where it lands on the scale e.g. where it intersects the line connecting the middle of indicators for 0.1 and 1.0.