forked from petteriTeikari/twoPhotonVessels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsegment_findEdges.m
35 lines (25 loc) · 1.11 KB
/
segment_findEdges.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
function edges = segment_findEdges(img, visualizeON)
[gx, gy] = gradient(img);
gradMag = sqrt(gx.^2 + gy.^2);
% smoothed_image = imgaussfilt(img,4);
myfilter = fspecial('gaussian',[3 3], 0.5);
smoothed_image = imfilter(img, myfilter, 'replicate');
[gx, gy] = gradient(smoothed_image);
gradMag_smooth = sqrt(gx.^2 + gy.^2);
edges = gradMag_smooth;
if visualizeON
regWeight1 = 0.01;
regWeight2 = 0.04;
regWeight3 = 0.08;
alpha = regWeight1 + regWeight2 .* exp(-regWeight3 .* edges);
rows = 2;
cols = 3;
subplot(rows,cols,1); imshow(img, []); title('OOF')
subplot(rows,cols,2); imshow(smoothed_image, []); title('OOF Smooth')
subplot(rows,cols,3); imshow(alpha, []); title('Alpha')
subplot(rows,cols,4); imshow(gradMag, []); title('GradMag')
subplot(rows,cols,5); imshow(gradMag_smooth, []); title('GradMag Smooth')
subplot(rows,cols,6); imshow(abs(gradMag - gradMag_smooth), []); title('abs(GradMag-GradMagSmooth)')
drawnow
pause(1.0)
end