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
2016년 12월 16일
... Did an attached image get dropped, or did the image never get attached?
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
2016년 12월 13일
It looks like there are 10 animals in that photo!
See my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
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)!
댓글 수: 0
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. :)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!