how to detect hand from body in pic ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tayyaba Abro
le 19 Jan 2018
Modifié(e) : Tayyaba Abro
le 19 Jan 2018
I have done skin segmentation and detection. When I tried to detect hand it also detects my arm area. Can you please tell me how can I detect hand from that arm ?
Here is the code:
folder=('C:\Users\Tayaba Abro\Desktop'); baseFileName=('hand.jpg'); fullFileName=fullfile(folder,baseFileName); format long g; format compact; fontSize = 20;
%IMAGE SEGMENTATION img=imread(fullFileName); img=rgb2ycbcr(img); for i=1:size(img,1) for j= 1:size(img,2) cb = img(i,j,2); cr = img(i,j,3); if(~(cr > 132 && cr < 173 && cb > 76 && cb < 126)) img(i,j,1)=235; img(i,j,2)=128; img(i,j,3)=128; end end end img=ycbcr2rgb(img); subplot(2,2,1); image1=imshow(img); axis on; title('Skin Segmentation', 'FontSize', fontSize); set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
%SEGMENTED IMAGE TO GRAYIMAGE grayImage=rgb2gray(img); subplot(2,2,2); image2=imshow(grayImage); axis on; title('Original Grayscale Image', 'FontSize', fontSize); set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
%GRAY TO BINARY IMAGE binaryImage = grayImage < 245; subplot(2, 2, 3); axis on; imshow(binaryImage, []); title('Binary Image', 'FontSize', fontSize);
% Label the image labeledImage = bwlabel(binaryImage); % labeling is the process of identifying the connected components in an image and assigning each one a unique label, like this: measurements = regionprops(labeledImage, 'BoundingBox', 'Area'); for k = 1 : length(measurements) thisBB = measurements(k).BoundingBox; rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],... 'EdgeColor','r','LineWidth',2 ) end
% Let's extract the second biggest blob - that will be the hand. allAreas = [measurements.Area]; [sortedAreas, sortingIndexes] = sort(allAreas, 'descend'); handIndex = sortingIndexes(2); % The hand is the second biggest, face is biggest. % Use ismember() to extact the hand from the labeled image. handImage = ismember(labeledImage, handIndex); % Now binarize handImage = handImage > 0; % Display the image. subplot(2, 2, 4); imshow(handImage, []); title('Hand Image', 'FontSize', fontSize);
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Data Workflows dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!