An alternative algorithm for blob detection
Since you have convolution and dilation you can use the Laplacian of Gaussian blob detector to detect the blobs and dilation to find the centre points. In MATLAB:

sigma = 3;

% Filter image with LoG
I = double(rgb2gray(imread('NCxQ8.jpg')));
h = fspecial('log', sigma*6, sigma);
B = -imfilter(I,h);
imagesc(B); pause;

% Threshold
B(B &lt; 5) = 0;
imagesc(B); pause;

% Dilate then compare to get all 
% local maximum in 3 pixel radius
Bd = imdilate(B,strel('disk',3));
imagesc(Bd); pause;
P = (B == Bd) .* B;
imagesc(P);

% Get point locations
loc = find(P &gt; 0);
fprintf('There are %d blobs\n',numel(loc));


Note: "NCxQ8.jpg" is the smaller image embedded in the post. Adjust sigma for larger ones.