How to count the number of occurrences of an item in an image?
6 ビュー (過去 30 日間)
古いコメントを表示
I have a series of images that display plastic shapes of different colour that looks like this:
![Sample Image](https://www.mathworks.com/matlabcentral/answers/uploaded_files/457299/Sample%20Image.jpeg)
There can be several of the same shape and colour (eg. multiple blue squares). I also have a template image:
![Template](https://www.mathworks.com/matlabcentral/answers/uploaded_files/457304/Template.png)
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');
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!