I am in the early stages of a project that is trying to analyse cell images in terms of the cell size (nice and easy) and morphology (potentially less easy, trying to find 'non-circular' cells which I suspect imfindcircles might struggle with). As part of this I need to batch process images, since there are far too many to count manually, and this is where MATLAB has come into play.
testimage.bmp is an example of the image I'm looking at:

As a disclaimer, I am relatively new to image processing, until now MATLAB for me has been solely used to process signals and do large matrix computation. I've so far written some very crude code below that finds the bright and dark cells within the image, stores the centres and radii as well as counting the number of each that it finds.
clearvars; close all;
im = imread('testimage.bmp');
imshow(im);
rmin = 6;
rmax = 11;
sensitivity = 0.95;
[brightcenter,brightradii] = imfindcircles(im, [rmin rmax], 'ObjectPolarity', 'bright', 'Sensitivity',sensitivity,'Method','TwoStage');
[darkcenter,darkradii] = imfindcircles(im, [rmin rmax], 'ObjectPolarity', 'dark', 'Sensitivity',sensitivity,'Method','TwoStage');
figure(2)
imshow(im)
viscircles(brightcenter, brightradii, 'Color', 'b');
viscircles(darkcenter,darkradii);
nbright = length(brightcenter);
ndark = length(darkcenter);
The biggest problem I have hit is the grid that is in the image - I think it was placed there in the days when they used to count the images manually:

As you can see, it detects a lot of circles on the grid. Turning the sensitivity down unfortunately results in the cells not being found before the false positives are removed. I tried messing around with thresholding and turning it into a b&w image first, however, because some of the cells are light and some dark, that again seems to mean the threshold levels are sufficiently wide that the grid is still there and I end up in the same situation as before. Intuitively, the image looks very clear, so I imagine I'm missing a very obvious function, and it may well not be imfindcircles() that I've been using to date to find the cells in the image and store their properties.
If anyone has any input on how to accurately count the cells that would be appreciated! The next bit once they've been found (looking at radii and morphology) I assume shall be reasonably straightforward as my understanding is that MATLAB has analysis tools that let me pull the radii, circularity etc.
Thanks as always :)
