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.

resized pic

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:

  1. Applied mean filter (for step 3)
  2. Thresholded image using adaptive thresholding (returning a binary image)
  3. Removed lines by checking connectivity, all lines are connected with above 100 pixels (for better connectivity mean filter was applied first)
  4. 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

  • $\begingroup$ Do the lines and blobs always appear in the same place? Could you not just crop out the lines? $\endgroup$ Jun 24, 2014 at 10:04
  • $\begingroup$ First, you could do if/else via BranchCreate/BranchEnable functions right? Second, you could always use Separa++, right? Third, I'm seeing blob analysis tools here: stemmer-imaging.dk/media/uploads/websites/documents/products/… $\endgroup$ Jan 10, 2017 at 11:44

1 Answer 1


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 < 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;

% Get point locations
loc = find(P > 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.

  • $\begingroup$ If lines are narrower than blobs diameter then you can also use erosion after thresholding to remove them. $\endgroup$
    – Louis Lac
    Aug 4, 2018 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.