Segmenatation for an image.

how can i segment and count the number of non overlapping blood cells in this image :
i need a code for doing this...

답변 (2개)

Image Analyst
Image Analyst 2013년 7월 22일

0 개 추천

First of all, look over my image segmentation demo. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Then look at how I filter out coins based on size. You need to do the same thing. If they overlap the size will be a lot bigger than if they don't overlap. So you just need to tweak the area value in my code and it should work for you.

댓글 수: 9

Image Analyst
Image Analyst 2013년 7월 22일
By the way, no need to do hough or edge detection like the tags you or someone added.
mecheal
mecheal 2013년 7월 22일
i look at your demo before ,i'm trying to modify it but it didnt work well , can you put me the modified version !
Image Analyst
Image Analyst 2013년 7월 22일
I might or might not have time to do that for you later today or this week. What was wrong? What happened when you typed in a different number for the size of the smaller objects?
mecheal
mecheal 2013년 7월 22일
i dont know what happened when i run ur code , there was alot of errors which i cant handel it , may be because im professional enough to do that please i help me i've to solve it ASAP , it willn't take alot time from you.
my code below dosn't give thedisered result , may it need some of modification , any one can help me to modify it , i'm so tired from this problem , i cant solve it anymore !!
a=imread('cells.gif');
threshold = graythresh(a);
a_bww = im2bw(a);
a_bw=~a_bww;
[labeled,numObjects]=bwlabel(a_bw);
[m,n]=size(a_bw);
s = regionprops(labeled, 'Centroid');
B = bwboundaries(a_bw);
imshow(a_bw)
hold on
for k = 1:numel(s)
c = s(k).Centroid;
text(c(1), c(2), sprintf('%d', k), ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle');
end
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 0.2)
end
hold off
The trick is to play with the threshold (what is being done implicitly by the graythresh() and im2bw() calls). Modifying your code somewhat and filling in the holes, I get:
a=imread('cells.gif');
a_bw = a < 200; %threshold at level=200
a_bw = imfill(a_bw, 'holes'); %remove holes
[labeled,numObjects]=bwlabel(a_bw);
[m,n]=size(a_bw);
s = regionprops(labeled);
B = bwboundaries(a_bw);
imshow(a_bw)
hold on
for k = 1:numel(s)
c = s(k).Centroid;
text(c(1), c(2), sprintf('%d', k), ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle');
end
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 0.2)
end
hold off
I'll let you figure out how to determine the overlapping cells, but to get you started, let's take a look at the area of each cell, i.e.,
Centroids = cat(1, s.Centroid);
Area = cat(1, s.Area);
figure();
%draw circles whose color is proportional to cell area
scatter( Centroids(:,1), Centroids(:,2), Area, Area, 'filled');
colormap jet, colorbar, hold on;
title('Area of each region');
The color of each circle is proportional to the area of that region (see the colorbar on the right side of the plot-- this gives the area->color relationship).
Note that some of the cells have markedly higher areas than the others. Can you figure out how to threshold out these areas?
mecheal
mecheal 2013년 7월 23일
great idea MR. matt ,, but i ran ur code , there was a small problem , u count a overlapped cells , i just want u to modify ur code to just count the UNOVERLAPPED CELLS ,,,WITH GREAT REGARDS,,,
Matt Kindig
Matt Kindig 2013년 7월 23일
See my comment immediately above. In general, I think it will be easier to count all cells (overlapped and non-overlapped alike), and remove the overlapping ones.
To identify the overlapping ones, you can (as Image Analyst stated) use an area criterion, removing all identified cells that exceed some threshold area. In my code above, I showed you how to visualize the areas of the various regions. I'll let you implement the logic about how to identify the overlapping cells.

댓글을 달려면 로그인하십시오.

질문:

2013년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by