How to count the number of detected objects in the image?

I want to develop an application that can count the number of objects in an image. It is not important to know the shape of the objects. I just need information on how many objects are in the image.

And I want to be able to implement it with many images. Is it possible? How to do it?

Here is my code:

a=citra1; a_citra_keabuan = rgb2gray(a); threshold = graythresh(a_citra_keabuan); a_bww = im2bw(a_citra_keabuan,threshold); a_bw = bwareaopen(a_bww,30); se = strel('disk',2); a_bw = imclose(a_bw,se); a_bw=~a_bww; [labeled,numObjects]=bwlabel(a_bw); 

numObjects shows the number of detected objects in images.

Here is an example of images

Images1

Images2

+4
source share
1 answer

To get started, you can fill in the images with different colors and then determine how many colors are left. So basically take a point, fill its neighbors with the same color, if some condition is met. This should leave an image with large margins (in front of the objects, if the conditions are correct). They can be counted then.

Here is a hint on how to do this: http://blogs.mathworks.com/steve/2008/02/25/neighbor-indexing-2/

0
source

Source: https://habr.com/ru/post/1492586/


All Articles