Introducing wrist trimming for forearm segmentation (Matlab)

I am trying to create a gesture recognition system for static poses. I am currently trying to perform a wrist trimming procedure before moving on to extracting a function.
I came across an algorithm (link here: http://admin.csie.ntust.edu.tw/IEET/syllabus/course/961_CS5014702_65_aGlnaDIucGRm.pdf ), but I'm not sure of its technical implementation (the document mentions another source that I don’t could find). 2 methods have been described, shown in the image below: enter image description here The first is based on the length of the wrist, the second is based on changes in the image contour. I am not sure how to implement this and I would be grateful for any help.

I have a simple idea (for the first method) where you scan pixels (starting from the bottom of the image), counting no. pixels in each row until you encounter a row that has more pixels than the previous row (indicating the beginning of the palm area). However, this suggests that the positioning of the hand is always upright. Any ideas to improve this so that the arm is not always upright or how to implement a contour-based approach (where would you find a sharp turn of the contour denoting the wrist)? I am completely new to Matlab. Thank you

Input Example:

enter image description here

Using the Miki solution, some outputs on more test images:

enter image description here enter image description here

Original Images:

enter image description here enter image description here

enter image description here

+4
source share
1 answer

A simple approach would be:

  • Rotate the image in accordance with the main axis
  • Calculate the difference of points on the contour line
  • Find the peaks in the differences vector and save the latter.

Here's the code (version 2):

% Read the image img = imread(path_to_image); % Binarize the image bw = img > 127; % Compute principal component orientation and rotate orientation = regionprops(bw, 'Orientation'); centroid = regionprops(bw,'centroid'); % Correct rotation according to centroid rotationAngle = -90 - orientation.Orientation; if(centroid.Centroid(1) < size(img,2)/2) rotationAngle = 90 - orientation.Orientation; end rotated = imrotate(bw, rotationAngle); rows = size(rotated,1); dist = zeros(rows, 1); % vector of distances of contour points imshow(rotated); hold on; % Compute the distances for r=1:rows s = find(rotated(r,:), 1, 'first'); e = find(rotated(r,:), 1, 'last'); if(~isempty(s) && ~isempty(e)) dist(r) = e - s; plot(s, r, 'xg'); plot(e, r, 'xr'); end end % Smooth for cleaner peaks %dist = smooth(dist, 15); % Find peaks [pks, locs] = findpeaks(-dist); % Select the peak carefully... th = 20; % A threshold on the distance among peaks loc = locs(end); for i = length(locs)-1 : -1 : 1 if(abs(locs(i) - loc) > th) break; else loc = locs(i); end end % Keep best ycut = loc; plot([1, size(rotated,2)], [ycut, ycut], 'b'); hold off; figure(); plot(dist); hold on; plot(locs, -pks, 'vg'); hold off; 

Result

enter image description here enter image description here enter image description here enter image description here

+5
source

All Articles