-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtract_centroid3.m
More file actions
47 lines (33 loc) · 832 Bytes
/
Extract_centroid3.m
File metadata and controls
47 lines (33 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function [centroids] = Extract_centroid3(I,i)
% Read the image and convert to gray-scale
%I = imread('images\t035.tif');
%imshow(I);
I_eq = adapthisteq(I);
%imshow(I_eq);
bw = im2bw(I_eq, .095);
%imshow(bw)
bw2=imfill(bw,'holes');
%imshow(bw2)
se90 = strel('line',3,90);
se0 = strel('line',3,0);
BWsdil = imdilate(bw2,[se90 se0]);
%imshow(BWsdil)
%title('Dilated Gradient Mask')
BWsdil=imfill(BWsdil,'holes');
bw3 = bwareaopen(BWsdil, 2050);
%imshow(bw3);
bw4=imfill(bw3,'holes');
imshow(bw4)
title(i)
s = regionprops(bw4,'centroid');
%imshow(s);
centroids = cat(1,s.Centroid);
%imshow(centroids)
%imshow(bw4)
%hold on
%plot(centroids(:,1), centroids(:,2), 'b.')
%hold off
%plot(centroids(:,1), centroids(:,2), '.')
%set(gca, 'YDir','reverse')
%axis([0 1024 0 1024])
end