Grouping objects (blobs) in an image
Afficher commentaires plus anciens
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')
Lines_crop: https://www.dropbox.com/s/ag31rp34gkm8um2/lines_crop.m Letter_crop: https://www.dropbox.com/s/n49dy4414c1f0dz/letter_crop.m
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.
Réponses (1)
syeda saba
le 25 Jan 2021
0 votes
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');
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!