-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtiptry.m
38 lines (29 loc) · 1.04 KB
/
tiptry.m
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
function tips = tiptry(imFolder,iImage, background)
disp('Finding all candidate tips!')
% clear all
% load('background20150428.mat')
%
%
% imFolder = 'C:\Users\linder\Documents\Data\PanNeuronal Behav\20150428\Raw Images';
images=dir([imFolder filesep '*.jpeg']);
gausSize = 2;
thresh = .06;
I = im2double(imread(images(iImage).name));
I = I(:,:,1);
Imb = I - background(:,:,1);
Imb = Imb(:,:,1);
If = imfilter(I,fspecial('gaussian', 6*gausSize,gausSize));
Ifmb = imfilter(Imb,fspecial('gaussian', 6*gausSize,gausSize));
Ibin = im2bw(Imb,thresh);
Ibinf = imfilter(Ibin,fspecial('gaussian', 6*3,3));
cc = bwconncomp(Ibinf);
stats = regionprops(cc, 'Area');
idx = find([stats.Area]>700);
BW = ismember(labelmatrix(cc), idx);
%Create Mexican hat-esque filter, apply to image to get tips
[X,Y] = meshgrid(-15:15, -15:15);
circle = double((X.^2 + Y.^2)<40) - .25; %Create circular filter
Icirc = imfilter(BW,circle);
tips = regionprops(Icirc, 'centroid');
disp('OK!');
end