Assignment 1: Colony Counting
Due 2 October 2007
For this assignment we will be designing an algorithm for counting colonies on an agar plate. The colonies are of different sizes, mostly round, mostly separated on the plate, and reasonably homogeneous in color.
Download the data files from here. Note that some of the images are taken with the agar plate facing down, some with it facing up. You don't need to be able to process both. Pick an orientation and stick with it. On the down-facing plates, the colonies will tend to look flatter than they do on the up-facing places.
You will also want to download the files:
Put the .c file in your lib directory and add it to the list of files in the makefile there. Put the .h file in your include directory. You will also want to add an include statement to your programs to include vision.h in them. Feel free to modify vision.h to incorporate any work that you do.
- The colony pictures for this assignment were taken on a red background. Using a suitable thresholding method, separate the colonies from the background. Thresholds on the green and blue channels will likely work well enough. The output of this step should be a binary mask. Represent the mask as an array (image) of unsigned chars. You can write out the mask to a file using the writePGM() function. If you use 0 for the background and 255 for the foreground then you will be able to visualize the mask easily.
Write the following functions. Each should take as an argument an
unsigned char array (input image), the number of rows, the number of
columns, and an unsigned char array (output image) to hold the output.
- Grow: executes either 4 or 8 connected growing (your choice). If you want, you can add a parameter to indicate the number of grow operations to execute.
- Shrink: executes either 4 or 8 connected shrinking (should be the opposite of your choice for growing). If you wish, add a parameter to indicate the number of shrinking operations to execute.
- Median: executes a median filter on the input image.
- Execute some combination of growing, shrinking, and median filtering to try and close up and speckles or holes in your regions and eliminate noise (non-colony foreground areas). Don't worry about getting rid of the boundary of the agar plate.
- Execute connected region identification on the mask. This will return both a region map and information about the top N regions (you specify N). The number of regions returned is your first estimate of the number of colonies. Think about whether it will likely be high or low.
- Using some simple shape measures or other region characteristics, try and eliminate unlikely colony shapes from consideration. Revise your estimate of the number of regions and print it out. You should also visualize the remaining colony regions by eliminating the unlikely regions from the mask.
- Execute a mean shift algorithm in RGB space on all of the pixels still left in the foreground (use the pixel values from the original image for this task). Initialize the mean shift algorithm to the mean of the remaining pixels, then iterate until it stabilizes. This will likely be the color distribution of the colonies. Use a threshold in RGB space based on this analysis to eliminate pixels from the mask that are not likely to be colony pixels. Make sure to visualize your result, and print out a new estimate of the number of colonies.
- At this point it may be worth running a shrink/grow/median filter combination again, re-running the connected component labeling, and printing out a final guess.
- Do something to try and break apart colonies that have grown together but are still clearly merged circles.
- Estimate the average region size of the colonies you find, then estimate the number of colonies in big chunky areas by taking the viable colony pixels and dividing by the average or median colony size. That technique might work when many colonies are too close together.
- Characterize differently shaped or sized colonies. Generate some features of colony shape or size and then show the different classes in different colors.
- Try some pre-processing steps on the original image, such as running a Gaussian or median filter on it prior to the binarization step.
- Automatically estimate the thresholds for separating the colonies from the background. Note that colony plates are almost always circular, so you can count on the four corners to be background only.
Follow the writeup instructions to create a web page for your assignment. Send the instructor an email with the code in a zip or tar file along with instructions on how to compile and run it as well as a pointer to the URL for the writeup.