Effacer les filtres
Effacer les filtres

Facing error in combining two m-files

1 vue (au cours des 30 derniers jours)
Explorer
Explorer le 20 Jan 2014
Commenté : Explorer le 21 Jan 2014
I have two codes having names skin_detection5.m and hand_detection4.m
I am trying to combine these two m-files but getting error.
combination.m is a file in which I tried to combine above mentioned m-file.
Input Image for skin_detection5.m
Input Image for hand detection
Both skin_detection5.m and hand_detection4.m are working fine for given input images. But I am trying to make a one m-file so that I do can both things i.e. skin detection and hand detection by running one m-file. But getting error mentioned below:
Attempted to access sortingIndexes(2); index out of bounds because
numel(sortingIndexes)=1.
Error in combination (line 129)
handIndex = sortingIndexes(2); % The hand is the second biggest, face is biggest.
  3 commentaires
Explorer
Explorer le 20 Jan 2014
Sure! I forgot to attach that file.
Explorer
Explorer le 20 Jan 2014
Modifié(e) : Explorer le 20 Jan 2014
I am expecting output as shown here

Connectez-vous pour commenter.

Réponse acceptée

Bruno Pop-Stefanov
Bruno Pop-Stefanov le 20 Jan 2014
The problem comes from line 111:
binaryImage = grayImage < 128;
Replace that line by the following:
binaryImage = ~grayImage;
Explanation:
In combination.m, you write (line 91):
grayImage = bin;
However, bin is a binary (or logical) image. Its values only are 0 or 1. When you write grayImage < 128, then you get an image with 1's everywhere because 0 and 1 are always < 128.
That explains the error you get at line 129: Since there is only one connected component in binaryImage (the whole image itself), then labeledImage (line 118), allAreas (line 127) and sortingIndexes (line 128) all correspond to only one connected component, instead of two or more (one for the head and one for the hand).
Therefore, when you try to access the second element of sortingIndexes, you get an error because sortingIndexes has only one element.

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by