How can I isolate objects in image?

13 views (last 30 days)
Francisco Salema
Francisco Salema on 6 Nov 2016
Commented: Image Analyst on 9 Nov 2016
Hello, I have an image that contains some chickens photographed from a top view, and I would like to count them through a Matlab function. My problem is that the chickens are so similar, in color, to the floor, making it difficult to go by the color. Also, since to ground is 'pointed', it is also difficult to go by texture, since the textures also seem kind of similar. These are some of the images it should be able to count:
and somee more similar to this ones. It is not a big problem if the function does not count the ones that are moving, once those sometimes are blurred, I'm only concerned with the static one's. Any help would be appreciated!

Answers (2)

Changoleon
Changoleon on 7 Nov 2016
Hi,
First of all, I would convert the image to grayscale. You can use rgb2gray or mean('name',3)
Next you should apply otsu's method (graythresh in Matlab) to find the threshold of the image. But as you said there is not too much difference between the chickens and the background. You could do some sort of filtering before applying grayhtresh to make the image smooth, and then find the threshold. Using that threshold, you can segment the image so that you end up only with your chickens. At the end, you can use [L,num] = bwlabel(segmented_image);
One more approach which is more reliable is cross-correlation. Once you find the aprroximate shape of one chicken, other chickens in the picture should look like the one you found ( more or less). Then you can count them.

Image Analyst
Image Analyst on 7 Nov 2016
Because the chickens are essentially the same color as the sand simply thresholding a gray scale image or even doing color segmentation is unlikely to be very robust. You might try a texture filter like stdfilt() or entropyfilt() but I even have doubts about that. I'd try optical flow in the Computer Vision System Toolbox. https://www.mathworks.com/products/computer-vision/features.html#object-tracking-and-motion-estimation
You might try optical filtering. I'd get the reflective spectrum of the chickens and of the sand and use a notch filter in front of the lens that is in the part of the optical spectrum where the chickens and the sand have the greatest reflectivity.
If you have some more money you can try a cheap thermal camera, assuming the sand and the chickens are not the same temperature.
  4 Comments
Francisco Salema
Francisco Salema on 9 Nov 2016
Thank you again, I tried to create a polyfit but it didn't work once the shadow on the pictures was not constant, in the end the way I solved, not perfectly, was to detect the color white in the image, in first aproach it detected also white in the floor so i blured the image with a gaussian filter removing that 'noise' and giving some acceptable results. Thank you so much for the cooperation!
Image Analyst
Image Analyst on 9 Nov 2016
But the chickens aren't white, or not totally white. And blurring might change the color of the white in the floor but it will also change the color of the white in the chickens. Maybe you should use size filtering instead.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!