MATLAB Answers

Grouping objects (blobs) in an image

11 views (last 30 days)
Aliyu Abdu
Aliyu Abdu on 31 May 2012
I want to group a number of blobs in my image: 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
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;
if isempty(rc)
if isempty(re)
median_space = median(spacevector); %Gets the median separation space.
% 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.


Sign in to comment.

Answers (0)


Translated by