Image segmentation and counting.
3 views (last 30 days)
Show older comments
Dear all, I am a BMEG student. I got a homework to count the cell of leaves by Matlab. The original figure is shown below.
And I used the following script to generate some result (I copied some code from examples).
rgb = imread('original.png'); %load image
rgb2 = rgb2gray(rgb); %change it to gray
rgb2 = imcomplement(rgb2); %invert the color
rgb2 = adapthisteq(rgb2, 'ClipLimit', 0.1); %enhance contract
BWdfill = imfill(im2bw(rgb2), 'holes'); %fill holes
BWnobord = imclearborder(BWdfill, 4); %remove the boundary cells
rgb_perim = bwperim(im2bw(BWnobord)); %find the boundary
overlay1 = imoverlay(rgb2gray(rgb),rgb_perim, [.3 1 .3]); %overlap figure with boundary
imshow(overlay1)
bw = BWnobord;
cc = bwconncomp(bw, 8);
graindata = regionprops(cc,'basic');
grain_areas = [graindata.Area];
length(grain_areas);
min(grain_areas);
max(grain_areas);
s = regionprops(BWnobord, {'Centroid'});
hold on
numObj = numel(s) %show the total number of cell
label_num = 0;
for k = 1 : numObj
if (grain_areas(k)> 200) & ( grain_areas(k) < 4000) %set area range
plot(s(k).Centroid(1), s(k).Centroid(2), 'ro'); %label selected ones
label_num = label_num + 1; %count number
end
end
hold off
label_num
And I got the following figure.
But the two circled regions didn't have a good segmentation. Does anyone have solution for this condition?
Thanks,
Xiaoquan.
0 Comments
Answers (2)
Ashutosh Kumar Upadhyay
on 10 Dec 2014
the size of those blobs may not fit into threshold range. try the code at http://in.mathworks.com/matlabcentral/fileexchange/48610-wavelet-based-noise-robust-image-segmentation with parameters as IsObjectLighter=1; NoOfScales_J=6; KernelBandwidth_h =1; NeighbourhoodDistance_RN = 0; ContrastThreshold_Th = 1; MorphSmoothRad=0; IsGelImage=1; smallRadiusofSpot=1; and apply area filtering operation on "seg" variable.
0 Comments
Sarah Salvino
on 24 May 2019
Hi, I was working in a similar project, could you please help me? My email adress is: sarahrsalvino@gmail.com
0 Comments
See Also
Categories
Find more on Image Segmentation and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!