How to use the 'imfilter' function to pick up blobs that are circular/linear

12 views (last 30 days)
I'm working on an image analysis project based around blob detection. This question has got to do with filter adjustment. The script I'm using picks up blobs that are more of a circular shape. However some images I'm now working with have blobs shaped more linear (Or even blobs that generally have an irregular shape). Below is the code I am currently using and it is a low pass filter. I've been messing about with it to try and pick up the irregular shapes:
PSF = fspecial('gaussian',7,7);
%'fspecial' creates predefined 2D filter, in this case a gaussian low pass filter
Blurred = imfilter(double(image_adapthisteq),PSF,'conv');
%imfilter 'conv' performs multidimensional filtering using convolution. Data type = 'double'
figure, imshow(uint8(Blurred)), title('Blurred')
I'm thinking the problem could have got to do with the gaussian LPF, however what substitute could you use if you still want to pick up circular blobs at the same time?
Or in the second line of coding 'conv' but I've tried replacing it and can't get any where! Any ideas where an adjustment can be made?

Answers (1)

Image Analyst
Image Analyst on 9 Jan 2014
The way I do it, and I think is more common, is to compute the perimeter squared to area ratio:
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area', 'Perimeter');
allAreas = [measurements.Area];
allPerimeters = [measurements.Perimeter];
circularities = allPerimeters .^ 2 ./ (4 * pi * allAreas);
roundObjectsIndexes = find(circularities < 3); % or whatever value you want.
% Extract only those blobs that meet our criteria, and
% eliminate those blobs that don't meet our criteria.
% Note how we use ismember() to do this.
keeperBlobsImage = ismember(labeledImage, keeperIndexes); % A labeled image
% If you want a binary image also, threshold the labeled image
binaryImageOfRoundObjects = keeperBlobsImage > 0;
  3 Comments
Troy Steiner
Troy Steiner on 18 Jul 2016
If I understand this correctly, this should remove circular blobs from a photo?
Should this be a working script?
Image Analyst
Image Analyst on 19 Jul 2016
Cormac. I don't know why you say that. Obviously it's possible to have blobs in different pictures have the same area - they just have to have the same number of pixels. If it's the same scene/objects and you have good control over lighting and positioning, it's not unusual to have areas that are very close, if not exact. So it is possible. And of course my code would still work. It just looks at blobs in one picture - each picture is an independent situation. It doesn't care what's in any other picture. You can keep or discard round blobs in one or more pictures.
Tony, the script is a partial script, not a full demo. It's assuming that you did image segmentation first to produce a binary image. Once you have that, then you can follow with the code in my script.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!