Effacer les filtres
Effacer les filtres

How to count the number of occurrences of an item in an image?

2 vues (au cours des 30 derniers jours)
Tawa Yenni
Tawa Yenni le 10 Déc 2020
Modifié(e) : Tawa Yenni le 10 Déc 2020
I have a series of images that display plastic shapes of different colour that looks like this:
Sample Image
There can be several of the same shape and colour (eg. multiple blue squares). I also have a template image:
Template
I want to count the number of occurence of the template image in the image.
This is what I have tried so far, which creates a binary image of only the blue shapes:
I = imread("im1.jpg");
template = imread("blue_square.jpg");
Ired = I(:,:,1);
Igreen = I(:,:,2);
Iblue = I(:,:,3);
blueOnly = Iblue - Ired - Igreen;
se = strel('disk', 15);
blueBin = imfill(imerode(imdilate(blueOnly, se),se),'holes');

Réponses (0)

Catégories

En savoir plus sur Read, Write, and Modify Image 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