Count Drawing Dots ImageJ

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Count Drawing Dots ImageJ

aandres

I need help counting dots generated using the paintbrush tool in ImageJ.  I tracked dendritic spine formation and spine loss on neurons using the color coded dots across a series of time lapse images.  For analysis, I stacked these images so I could align them.  I would like to automate the counting of these colored dots to quickly analyze the numbers in excel.  The brush width is 5 pixels.  I've been playing around and have this much:

lower = 100;
upper = 150;
green = 0;
red = 0;
yellow = 0;
black = 0;
other = 0;
for (y = 0; y < getHeight; y++) {
  for (x = 0; x < getWidth; x++) {
    v = getPixel(x,y);
    r = (v>>16)&0xff;  // extract red byte (bits 23-17)
    g = (v>>8)&0xff; // extract green byte (bits 15-8)
    b = v&0xff;       // extract blue byte (bits 7-0)
    if (r > upper && g > upper && b < lower) yellow++;
    else if (r < lower && g > upper && b < lower) green++;
    else if (r > upper && g < lower && b < lower) red++;
    else if (r < lower && g < lower && b < lower) black++;
    else other++;
  }
}

I checked using the same macro, if the brush width is 5 pixels it turns out to return 21 pixels/dot.  It would also be helpful if the numbers could automatically be populated into excel.  Thanks for the help!