-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclearVessel_v1.m
98 lines (80 loc) · 2.29 KB
/
clearVessel_v1.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
function clearlung=clearVessel_v1(lung)
%akçiðerler siyah arka plan beyaz yapýldý
tmp = lung;
%maks=max(lung(:));
tmp(tmp~=700)=0;
tmp(tmp==700)=255;
figure(100);
imshow(tmp,[]);
title('akciðer sýnýrlarý belirleme');
hold on;
borderLung=visboundaries(tmp, 'Color', 'r', 'EnhanceVisibility', true, 'LineStyle', '-'); %akçiðerin sýnýrlarý
hold off;
%akciðerdeki damarlarý belirginleþtirme
lung(lung>-140) = 255;
originalImage=lung;
figure(101);
imshow(lung,'DisplayRange',[]);
title('clearVessel_v1 lung(lung>-140) = 255; damarlar belirginleþti ');
hold on;
visboundaries(tmp, 'Color', 'r', 'EnhanceVisibility', true, 'LineStyle', '-');
hold off;
tresholdImage = im2bw(lung, 0.5);% akciðer,damar ve arka planý ayýrma
koordinat_X=borderLung.Children(1,1).XData;
koordinat_Y=borderLung.Children(1,1).YData;
for i=1:length(koordinat_X)
a=koordinat_Y(1,i);
b=koordinat_X(1,i);
if(isnan(a) || isnan(b))
continue;
end
tresholdImage(a,b)=0;
end
figure(99);
imshow(tresholdImage,[]);
title('vessel tresholdImage');
[L, num] = bwlabel(tresholdImage,8);
num
RGB = label2rgb(L, @jet, 'k');
figure(98);
title('connected component labeling uy');
imshow(RGB,[]);
%Determine the connected components:
CC = bwconncomp(tresholdImage, 8);
%Compute the area of each component:
S = regionprops(CC, 'Area');
SegmentValue=[S.Area];
L = labelmatrix(CC);
BW2 = ismember(L, find([S.Area] >= 100)); %akçiðerde 80 pikselden küçük alankarý temizleme
[L, num] = bwlabel(BW2,8);
num
RGB = label2rgb(L, @jet, 'k');
figure(97);
imshow(RGB,[]);
title('akçiðerde 80 pikselden küçük alankarý temizlendi');
background_r=RGB(2,2,1);
background_g=RGB(2,2,2);
background_b=RGB(2,2,3);
[rows, cols] = size(originalImage);
clearlung=originalImage;
minimum=min(originalImage(:));
minimum
maksimum=max(originalImage(:));
maksimum
figure(90);
imshow(originalImage,[]);
title('originalImage');
for i = 1:rows
for j = 1:cols
if((0==RGB(i,j,1) & 0==RGB(i,j,2) & 0==RGB(i,j,3)) )
clearlung(i,j)=originalImage(i,j);
elseif (background_r==RGB(i,j,1) & background_g==RGB(i,j,2) & background_b==RGB(i,j,3))
clearlung(i,j)=1100;
else
clearlung(i,j)=minimum;
end
end
end
figure(96);
imshowpair(originalImage,clearlung,'montage');
title('clear vessel')