Image segmentation and counting.
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Ashutosh Kumar Upadhyay
2014년 12월 10일
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
Sarah Salvino
2019년 5월 24일
Hi, I was working in a similar project, could you please help me? My email adress is: sarahrsalvino@gmail.com
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!