Grouping objects (blobs) in an image

2 views (last 30 days)
Aliyu Abdu
Aliyu Abdu on 31 May 2012
Answered: syeda saba on 25 Jan 2021
I want to group a number of blobs in my image: https://www.dropbox.com/s/0d6mrvssx9vr3yg/im.png. The blobs are separated at certain distances from each other. Below is the code I'm working with;
clc, close all, clear all
I = imread('im.png');
re = I;
spacevector = zeros;
n = 0;
lines = 0;
while 1
[fl re]=lines_crop(re); %fl= first line, re= remaining image
%imgn=fl;
lines = lines + 1;
rc = fl;
while 1
%Fcn 'letter_crop' separate letters in a line
[fc rc space]=letter_crop(rc); %fc = first letter in the line
%rc = remaining cropped line
%space = space between the letter
%cropped and the next letter
n = n + 1;
spacevector(n)=space;
if isempty(rc)
break;
end
end
if isempty(re)
break
end
end
median_space = median(spacevector); %Gets the median separation space.
%figure,imshow(I);
% title('Original binary Image')
I have gotten the space between adjacent blobs in the "space_vector" as well as the "median" distance. What I want to do is to group blobs that are separated by the distance "median" in each line and assign a number such that the first group would be "1", second group "2".....and so on. I can't figure out how to do it . Please can anyone help? Thanks in advance.

Answers (1)

syeda saba
syeda saba on 25 Jan 2021
clear all;
close all;
clc;
%1. Display the image.
I=imread('blobs.png');
subplot(2,2,1);
imshow(I);
title('Original Image');
%2. Adjust the histogram so that 1% data is saturated at high and low intensities.
H1=fspecial('motion',50,45); % inducing perpendicular motian blur to the original image
blurred_im=imfilter(I,H1);
subplot(2,2,2);
imshow(blurred_im);
title(' motion blurred image');

Categories

Find more on Images in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!