Click here to Skip to main content
15,170,971 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi. i m working on a project which is related to digital image processing but i can't count the overlapped objects it take multiple overlapped objects as one object. please tell me which method i can use for this problem.... and overlapped objects may be two or more than two..... so please tell me that method which is suitable for this.


What I have tried:

I = imread('H:\traningimage\005cell.png');
figure; imshow(grayI)
grayI=rgb2gray(I);
%figure; imshow(grayI)
%imcredit('Image courtesy of Dr. Ramiro Massol')
I_eq = adapthisteq(grayI);
%figure; imshow(I_eq)
bw = im2bw(I_eq, graythresh(I_eq));
figure; imshow(bw)
bw2 = imfill(bw,'holes');
bw3 = imopen(bw2, ones(1,1));
ero=strel('disk', 1);
erodedI = imerode(bw3,ero);
figure; imshow(erodedI);title('erogen image');
bw4 = bwareaopen(erodedI, 10);
bw4_perim = bwperim(bw4);
overlay1 = imoverlay(I_eq, bw4_perim, [.3 1 .3]);
figure;imshow(overlay1)
mask_em = imextendedmax(I_eq, 10);
figure;imshow(mask_em)
 mask_em = imclose(mask_em, ones(3,3));
mask_em = imfill(mask_em, 'holes');
mask_em = bwareaopen(mask_em, 10);
overlay2 = imoverlay(I_eq, bw4_perim | mask_em, [.3 1 .3]);
imshow(overlay2)

%********************************************
s  = regionprops(erodedI,'centroid');
centroids = cat(1, s.Centroid);
imshow(overlay2)
hold on
plot(centroids(:,1), centroids(:,2), 'r*')
hold off
%****************************************************************
stats = regionprops('table',erodedI,'Centroid',...
    'MajorAxisLength','MinorAxisLength');
centers = stats.Centroid;
diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2);
radii = diameters/2;
hold on
viscircles(centers,radii);
hold off
 removeCC = bwareaopen(bw4,1);
 cc=bwconncomp(removeCC);
 Objects_per_unit_area=cc.NumObjects/(size(removeCC,1)*size(removeCC,2));
  imshow(I);title(['number of objects in this image =',num2str(cc.NumObjects)])
Posted
Updated 4-Nov-19 4:40am

1 solution

I'd strongly suggest to ask this question on Matlab forum: Home - MATLAB Central[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900