top of page

Finger Counting

Our current methodology to count the number of fingers relies on finding the intersection between a circle and a binary image mask of the hand as shown in the flowchart below. 

 

We first take a clean image of a hand as shown below. Then using the rgb2gray function and the imbinarize function, we are able to convert the image to a binary mask which includes only the hand.

 

 

Then using the regionprops command, we can determine the centroid of the hand, and the major and minor axis lengths of an ellipse with an equivalent moment of area. We can then virtually shift all of the points so that the centroid of the hand is the origin in a coordinate system. From here, we use the mean of the major and minor axis lengths of the white region as a diameter for a circle with which we wish to investigate the number of fingers.

 

The intersection points can be found by converting the shifted cartesian coordinates of the hand pixels to polar coordinates and indexing the theta coordinates where the r coordinates are within some tolerance of the radius of the investigation circle.

 

If we plot these theta values vs their vector index, we can visualize these points as shown below.

 

 

These values are clearly not usable as the theta value jumps significantly from index to index due to how MATLAB internally generates the vector of theta values. Sorting these values from smallest to largest results in a graph like the one below.

 

 

From here, determining the number of fingers is simple as all we need to do is group the number of regions where the theta value is nearly constant. We can do this by creating a vector of indices where the gradient in the sorted theta vector is lower than some tolerance. This vector can also be treated like a binary image so we can use the function bwconncomp to determine the number of connected components. As we assume that the wrist is detected by this method, we subtract one from the number of connected components to get the final number of fingers in the image.

 

 

One benefit of this method is that it does not assume an orientation of the hand, however it has many shortcomings. For example, if the background of the image is not plain white, we will have to significantly increase the complexity of the code to generate the binary image mask. Furthermore, we believe that the accuracy of the algorithm can be further improved by using multiple circles rather than just one as there may be certain scenarios in which the region of the circle going through the thumb also passes through the palm without passing through the background first.

QQ截图20220405195949.png

Figure 1: Flow Chart of Finger Counting

QQ截图20220406170103.png

Figure 2: Binary Image Mask of Hand

QQ截图20220406171013.png

Figure 3: Finger Investigation Circle

QQ截图20220406172157.png

Figure 4: Circle Intersection and Finger Candidate Points

QQ截图20220406172232.png

Figure 5: Unsorted Theta Values of Candidate Finger Points

QQ截图20220406172239.png

Figure 6: Theta Values of Finger Candidate Ponts

QQ截图20220406172248.png

Figure 7: Detected Fingers

bottom of page