This page is a part of CVprimer.com, a wiki devoted to computer vision. It focuses on low level computer vision, digital image analysis, and applications. It is designed as an online textbook but the exposition is informal. It geared towards software developers, especially beginners, and CS students. The wiki contains mathematics, algorithms, code examples, source code, compiled software, and some discussion. If you have any questions or suggestions, please contact me directly.

# Counting sealed brood in bee frames

### From Computer Vision Primer

This came as a question from one of our users. The picture explains the problem: there is a bee frame with several hundred sealed brood. They are visible as tan hexagons (the dark circles are empty cells). Now, count them! Just like that – **an outdoors photo taken with a regular digital camera, no registration, no calibration**, etc.

The problem is interesting but also quite challenging. The sealed cells aren't separated enough from each other to count them one by one with 100% accuracy. For that the image would need a higher resolution. If, however, the goal is just an estimate, Pixcavator can help. Then the task is less about counting and more about measuring… and some elementary school math.

First I cropped the image. Then I analyzed it with 100-130 settings, no shrinking. The result is 311 dark objects (clusters of empty cells) with the average size 1,255. So the total area of the empty cells is

*311*1,255 = 390,305.*

Since the image is 1,394x709, the area covered by sealed cells is

*1,394*709 - 390,305 = 598,041.*

Just in case I decided to validate this number from another source. I analyzed the negative with 100-110 settings. Then I just picked the largest object in the table - the cluster of all sealed cells. Its area is 613,814. Since the empty cells inside of this area aren't taken into account, the result is higher than the first estimate. The difference is however less than 3%.

At this point you need to estimate the size of a cell. Looking at a few individual cells in the table may give you an estimate, but it would take some work with Excel. Instead I did actual measuring - on the screen. I counted 10 cells in a row and measured the length with a ruler - 34 mm. So each cell is about 3.4x3.4 mm. Next I measured the image - 270x136 mm. So the number of cells is

*270*136/(3.4*3.4) = 36,720.*

(The user won’t need this computation because the actual number is known). Then the size of the cell is

*(the size of the image in pixels) / (the number of cells) = 1,394*709/36,720 = 269.*

Finally, the number of sealed cells is

*(the total area) / (the size of each) = 598,041/269 = 2,223.*

The hand counted number is 2,198. **The error is about 1%!**

You can reproduce these results with Pixcavator and full version of the image above.