-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_postseg_demo.m
65 lines (53 loc) · 2.01 KB
/
my_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
im_Files = dir('data/DRIVE/test/testSegmented/*.bmp');
im_TFiles = dir('data/DRIVE/training/trainSegmented/*.bmp');
Range=(1:size(im_Files,1));
parpool;
for ra=Range
image_name = im_Files(ra).name;
strL = sprintf('%d. %s',ra,image_name);
disp(strL);
segImg = imread(image_name);
segVess = segImg(:, :, 1);
[img, conncomp, vesselSkeleton] = mypostseg( segVess );
[VesselGraph, V, vesselSkeleton2] = extractGraph(vesselSkeleton);
vesselSkeletonPixel2 = roundSkel(vesselSkeleton2);
vesselJunctionPixel = roundJunctions(V);
[Rows,Cols] = size(img);
centerLine = zeros(Rows,Cols);
for i = 1: length(vesselSkeletonPixel2)
L = vesselSkeletonPixel2{i};
[rows, cols] = size(L);
for row=1:rows
centerLine(L(row, 1), L(row, 2))=true;
end
end
centerLine(vesselJunctionPixel(:, 1), vesselJunctionPixel(:, 2)) = false;
[pathstr,name,ext] = fileparts(image_name);
strStore = sprintf('data/DRIVE/test/centerline/%s.bmp',name);
imwrite(centerLine,strStore);
%Training
image_name = im_TFiles(ra).name;
strL = sprintf('%d. %s',ra,image_name);
disp(strL);
segImg = imread(image_name);
segVess = segImg(:, :, 1);
[img, conncomp, vesselSkeleton] = mypostseg( segVess );
[VesselGraph, V, vesselSkeleton2] = extractGraph(vesselSkeleton);
vesselSkeletonPixel2 = roundSkel(vesselSkeleton2);
vesselJunctionPixel = roundJunctions(V);
[Rows,Cols] = size(img);
centerLine = zeros(Rows,Cols);
for i = 1: length(vesselSkeletonPixel2)
L = vesselSkeletonPixel2{i};
[rows, cols] = size(L);
for row=1:rows
centerLine(L(row, 1), L(row, 2))=true;
end
end
centerLine(vesselJunctionPixel(:, 1), vesselJunctionPixel(:, 2)) = false;
[pathstr,name,ext] = fileparts(image_name);
strStore = sprintf('data/DRIVE/training/centerline/%s.bmp',name);
imwrite(centerLine,strStore);
end
poolobj = gcp('nocreate');
delete(poolobj);