To find the coordinates of the following image?

E
Ezequiel · Oct 31, 2020 · 1.9K views
Question
I want to find the coordinates of the middle fingure in both hands.
Expert Answer
Profile picture of Neeta Dsouza
Neeta Dsouza PhD Expert
Answered Nov 20, 2025
Here's a start:
 
 
 
grayImage = rgb2gray(rgbImage);
mask = grayImage > 128; % or whatever value works to get the hand.
mask = imfill(mask, 'holes');
mask = bwareafilt(mask, 1); % Take largest blob.
props = regionprops(mask, 'BoundingBox');
xLeft = props.BoundingBox(1)
xRight = xLeft + props.BoundingBox(3)
hold on;
rectangle('Position', props.BoundingBox, 'EdgeColor', 'y', 'LineWidth', 2)

You can easily determine whether the hand is oriented like on the left of right by splitting the mask into the top half and bottom half and finding if the centroid of bottom half is to the left or right of the top half

 

topHalf = false(size(mask));
[rows, columns] = size(mask);
topHalf(floor(rows/2)+1:end, :) = false; % Erase bottom half.
propsTop = regionprops(topHalf, 'Centroid');
bottomHalf = false(size(mask));
bottomHalf(1:floor(rows/2), :) = false; % Erase top half.
propsBottom = regionprops(topHalf, 'Centroid');
if propsTop.Centroid(1,1) < propsBottom.Centroid(1,1)
    % Forearm is on the right.
    xMiddle = xLeft; % Middle finger is on the left.
else
    % Forarm is on the left
    xMiddle = xRight; % Middle finger is on the right.
end
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!