mikejin

Is there any program for automatically counting objects in a picture?

Recommended Posts

mikejin    0

Hi I guess this is a question about image analysis. I'm looking for an automated method of counting the number of bats in pictures, like the one below. I don't have a background in CS, so preferably I need something that doesn't require any programming. Please let me know if there exists anything that fits this purpose. Thanks in advance.

FYI this is for my senior project. I'm studying how Mexican free-tailed bats synchronize their emergence. For instance, how does their echolocation intensity correlate with this group behavior. (Maybe someone will be interested in this)

IMG_4399.thumb.JPG.3ecc358efeaca7ada2e56ad83b53d652.JPG4.thumb.PNG.6114e0157614a4ad9f2fa2be904c5e35.PNG

Share this post


Link to post
Share on other sites
StringJunky    1511
fiveworlds    68
Posted (edited)

I could probably write something but in order to get a fairly accurate count I would need a video or at least a couple of pictures.

Basically you can find the differences between 2 pictures aka the moving birds. Then create a spritesheet from the data and all you would need to do is count the length of the returned array.

If you don't feel like coding it yourself you can use adobe photoshop to find differences between 2 photos and https://www.codeandweb.com/texturepacker/tutorials/how-to-create-a-sprite-sheet will generate the spritesheet and return a count of sprites.

 

 

Edited by fiveworlds

Share this post


Link to post
Share on other sites
Klaynos    724

If you cut out the tree area you could use the contrast between bird and sky and count the number of continuous areas. 

It's far from perfect. 

https://xkcd.com/1425/

  • Upvote 1

Share this post


Link to post
Share on other sites
mikejin    0
23 hours ago, fiveworlds said:

I could probably write something but in order to get a fairly accurate count I would need a video or at least a couple of pictures.

Basically you can find the differences between 2 pictures aka the moving birds. Then create a spritesheet from the data and all you would need to do is count the length of the returned array.

If you don't feel like coding it yourself you can use adobe photoshop to find differences between 2 photos and https://www.codeandweb.com/texturepacker/tutorials/how-to-create-a-sprite-sheet will generate the spritesheet and return a count of sprites.

 

 

It would be great if you could help me write some simple codes. If that's cool with you, I'll send you a video (I'll try to get some footage this weekend). If not, it's all good, since it's probably too much to ask for.

Or could you maybe tell me more detail about how to use photoshop and spritesheet to count the difference? 

Share this post


Link to post
Share on other sites
mikejin    0
17 hours ago, Klaynos said:

If you cut out the tree area you could use the contrast between bird and sky and count the number of continuous areas. 

It's far from perfect. 

https://xkcd.com/1425/

Thanks for the reply. Is there any software that can do the counting? I've tried ImageJ, but the cell counter plugin seems to only recognize circular objects.

Share this post


Link to post
Share on other sites
Klaynos    724

None that I know of out of he box. I've done something similar in the past using both R and MATLAB. But you'd need to write the code to do it. 

Share this post


Link to post
Share on other sites
fiveworlds    68

var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var img = new Image();
img.onload = function() {
    canvas.width = img.width;
    canvas.height = img.height;
    context.drawImage(img, 0, 0 );
    var count = 0;
    var myData = context.getImageData(0, 0, img.width, img.height);
    for(var i=0; i<myData.data.length; i=i+4){
        if(myData.data[i]>90||myData.data[i+1]>90){
            myData.data[i] = 0;
            myData.data[i+1] = 0;
            myData.data[i+2] = 0;
            myData.data[i+3] = 0;
        } else {
            count = count + 1;
        }
    }
    context.putImageData(myData,0,0);
    document.body.appendChild(canvas);
    alert(count);
}
img.src = 'image.jpg';

That will remove the sky from the image after which you can crop out the trees. Which will give you an image that looks like this.

LGIW5tO.png

Then you can use imagej analyse>analyze particles to get a count for the number of birds in the picture. Which worked out for me at 1388 since the camera didn't catch the birds in great detail. Most of the birds wound up being cut into 2 blobs so there are approx 700 birds.

  • Upvote 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now