Please identify how many animals are in the provided image,

4 次查看(过去 30 天)
I have to make matlab code to determine how many animals are in this picture for a homework project. I have to count the number of animals and show a picture. I know how to use imread and imshow but I dont know how to count images and isolate them. Please help I am very confused!!!!!!
  2 个评论
Walter Roberson
Walter Roberson 2016-12-16
... Did an attached image get dropped, or did the image never get attached?
Image Analyst
Image Analyst 2016-12-17
There was no image when I replied. I don't know if there was when Simone replied (sounds like there was) but if there was, it's not there now. I wonder if it has to do with chicken counting like the other person asked about. The other common animal counting subject is fish.

请先登录,再进行评论。

回答(2 个)

Image Analyst
Image Analyst 2016-12-13
It looks like there are 10 animals in that photo!
I can tell you're confused, because "determine how many animals" and "count images" are two different things - they count different things (animals and images)!

Simone Hernandez
Simone Hernandez 2016-12-16
Hi! So I am not sure if I completely solved your problem, but I hope this helps.
So the code below first takes the image and inverts the colors, so that it is easier to isolate the animals in the photo. The function bwareaopen removes any extra noise in the picture. You can take a look and have a play around with the values depending on the photo itself.
Code:
bw = ~bw; bw = bwareaopen(bw,3000); stats = regionprops(bw, 'BoundingBox', 'Centroid'); imshow(bw)
Then the following simply recognizes the clusters in the image, and isloates them in red boxes. I was playing around with other photos to ensure that the code was working, but in some photos, it is hard to isolate two objects on top of one another.
hold on
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
plot(bc(1),bc(2), '-m+')
end
hold off
Hope this helps, and sorry for the lack of explanation, but you can take it upon yourself to learn what each individual function does. :)

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by