-
Notifications
You must be signed in to change notification settings - Fork 0
/
postseg_demo.m
39 lines (32 loc) · 1008 Bytes
/
postseg_demo.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
%% Demonstrate use of postseg
segImg = imread('data/29_training_vessels.png');
% to gray lvl (image is binary)
segImg = segImg(:, :, 1);
mask = imread('data/29_mask.gif');
% load('../Rolando_CODE/WIDE dataset/image_08.mat');
% segImg = I > 0.06;
% mask = zeros(size(segImg)) + 255;
[img, conncomp, vesselSkeleton] = postseg(segImg, mask);
%vesselSkeletonPixel = roundSkel(vesselSkeleton);
%% centerline
figure(1)
% If need to show skeleton without image, the origin of the plot will be
% different from imshow
imshow(img);
hold on;
for i = 1: length(vesselSkeleton)
L = vesselSkeleton{i};
plot(L(:, 2), L(:, 1), '-', 'Color', rand(1,3));
%plot(L(:, 2), L(:, 1), 'black.');
end
%% Connected components
figure(2)
numPixels = cellfun(@numel, conncomp.PixelIdxList);
plot(numPixels);
xlabel('Connected components');
ylabel('Number of pixels');
%% Generate graph
figure(1)
hold on
[VesselGraph, V, vesselSkeleton] = extractGraph(vesselSkeleton);
scatter(V(:, 2), V(:, 1)); % x-y wrong order?