An alternative algorithm for blob detection Here's a sample image of my experiment which is to be processed for finding the information of all the blobs (centre, dimension etc.). Basically the image contains some noise, few bold lines, and of course few blobs.



Full size image (12Mb)

My aim is to program a FPGA using an image processing package "Sapera APF". Sapera APF is an application for programming Teledyne DALSA frame grabbers to perform image processing. And unfortunately it doesn't allow us to write code in conventional way, neither allows to use basic coding features (if else statements, loops etc.) but only supports some inbuilt functions in form of code blocks, and we can only arrange these blocks.
FYI, Here's a link to a list of functions supported by Sapera:
https://www.dropbox.com/s/9f5qc9uki0lsalu/sapera_functions.docx

Now my first objective was to test my algorithm on matlab thereafter implementing it on Sapera. Here is my approach in matlab:


Applied mean filter (for step 3)
Thresholded image using adaptive thresholding (returning a binary image)
Removed lines by checking connectivity, all lines are connected with above 100 pixels      (for better connectivity mean filter was applied first)
Now since only blobs were remaining, their locations were identified (with grayvalue=255) and corresponding pixels were taken in original image.


This is a simple algorithm which works fine in matlab. But the real problem is that for step 2 (i.e. connectivity) of course I had to write loops going to each pixel checking for connectivity, which can't be done in Sapera. So I am looking for some other simpler algorithm to separate blobs in my images, without using loops and conditional statement, so that it can be implemented in Sapera, but now I just need its matlab code or algorithm.

Edit:
I cannot crop out strip containing blobs because other images may contain lines very close (maybe overlapping) to blob. For example, https://www.dropbox.com/s/m2j5pqo6stg4s1z/h125_s_-30.bmp
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.