Red object detection picking up yellow color.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Adam Hicks
le 13 Déc 2017
Modifié(e) : Adam Hicks
le 13 Déc 2017
Part of my program isolates the red objects in an image and displays them in a binary image. It works well but has been including yellow objects which is an issue. I've tried adjusting the values in my code with no luck.
img = imread(imname);
gimg = rgb2gray(img);
red = imsubtract(img(:,:,1), gimg);
red = medfilt2(red, [4 4]);
red = im2bw(red, 0.15);
redObjects = bwareaopen(red, 200);
The red objects in my image are all exactly [1 0 0]. Is there a way to do this with hsv that might be more accurate or am I missing something simple here?
0 commentaires
Réponse acceptée
John D'Errico
le 13 Déc 2017
Modifié(e) : John D'Errico
le 13 Déc 2017
You extracted ONLY the red channel. Then you looked for red colors. But there are other colors which have the red channel maxxed out, yet are not red. Color is THREE dimensional. If you ignore the other two channels, expect to fail at your task. Your methodology would have found the [1 1 0] color too, calling it "red".
If your goal is to find ONLY colors which are explicitly and exactly [1 0 0], then use tools that can do so.
2 commentaires
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!