-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvasC.m
More file actions
107 lines (94 loc) · 2.61 KB
/
vasC.m
File metadata and controls
107 lines (94 loc) · 2.61 KB
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
98
99
100
101
102
103
104
105
106
107
%function [cc, BW] = vasFunc(p,r, I)
%
%mike = imbinarize(imread("VasculatureGT section30.tif"));
p = imread('Purple_30.tif');
%I0 = rgb2gray(p);
maskp = hysteresis3d(p,0.45,0.4,8);
se = strel('sphere',8);% se =offsetstrel('ball',12,12);
maskp1 = imdilate(maskp,se);
maskp2 = imerode(maskp1,se);
maskp2 = rgb2gray(maskp2);
imshow(maskp2)
%
%load('masks.mat');
I = im2double(imread('merged_30.tif'));
%I = im2double(imread('30.tif'));
%I = imread('mask2.PNG');
r= im2double(imread('Red_30.tif'));
% g1 = g1+maskedRGBImage;x
% p = imread('purple.tif');
% g0 = imread('green.tif');
%r = im2double(imread('redtwo.tif'));
main =I-maskp2;
gr = (rgb2gray(main));
%gr = (rgb2gray(I));
I2 = ordfilt2(gr,22,true(5));
% I2 = medfilt2(gr>10,[3 3]);
% imshow(I2)
%load('masks.mat');
%I = im2double(imread('S4_LYVE1_Align_06_07_21_1_2.tif'));
%I = imread('mask2.PNG');
% g1= imread('S4_LYVE1_Align_06_07_21_1.tif');
% g1 = g1+maskedRGBImage;x
% p = imread('purple.tif');
% g0 = imread('green.tif');
%g=rgb2gray(maskedRGBImage-r);
%g = imgaussfilt(g,1);
%g=rgb2gray(I);
%
% se = offsetstrel('ball',2,2);
% g = imdilate(g,se);
% g = imerode(g,se);
% % %imshow(g)
%I2 = medfilt2(medfilt2(medfilt2(medfilt2(gr>89,[2 2]))));
% imshow(I2);
%BW1 = edge(g,'canny',0.9);
%figure
%imshow(g)
img= hysteresis3d(gr,0.44,0.4,8);
figure
imshow(img)
% se1 = strel('sphere',4);% se =offsetstrel('ball',12,12);
% se2 = strel('sphere',1);% se =offsetstrel('ball',12,12);
%
% img1 = imdilate(img,se1);
% img2 = imerode(img1,se1);
%
%
% imshow(img2)
%img = imbinarize(imfill(img,'holes'));
%img1 = 1- img;
cc = bwconncomp(img);
%img =imgaussfilt(img,1);
% figure
BW = bwareafilt(imbinarize(img),[5 2550]);
%BW = bwareafilt(BW,[10 1000]);
% se1 = strel('sphere',8);% se =offsetstrel('ball',12,12);
% maskp3 = imdilate(BW,se1);
% maskp4 = imerode(maskp3,se1);
% %maskp4 = rgb2gray(maskp4);
% imshow(maskp4)
% BW = bwareaopen(img, 10);
imshow(BW)
% labeledImage = bwlabel(img);
% labeledImage(labeledImage == 8) = 3; % Blob #8 is now merged with 3
se1 = strel('sphere',4);% se =offsetstrel('ball',12,12);
se2 = strel('sphere',3);% se =offsetstrel('ball',12,12);
BW1 = imdilate(BW,se1);
BW2 = imerode(BW1,se2);
BW3 = bwareafilt(BW2,[15 1550]);
%BW = bwareafilt(imbinarize(img), 16);
imshow(BW3)
%img1 = bwconvhull(img,'objects');
[B,L,N] = bwboundaries(BW);
figure;
imshow(I);
hold on;
for k = 1:length(B)
boundary = B{k};
% if(k > N)
plot(boundary(:,2), boundary(:,1), 'y', 'LineWidth', 1.5);
% else
% plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 2);
% end
end