-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistration_performance_PAS_IF.m
More file actions
124 lines (112 loc) · 3.27 KB
/
registration_performance_PAS_IF.m
File metadata and controls
124 lines (112 loc) · 3.27 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
for i = 1:size(registrated1,1)
for j = 1:size(registrated1,2)
if registrated1(i,j, 1) == 0 && registrated1(i,j, 2) == 0 && registrated1(i,j, 3) == 00
% Change from white to our gray level
registrated1 (i,j,1) = 240;
registrated1 (i,j,2) = 240;
registrated1 (i,j,3) = 240;
end
end
end
figure();imshow(registrated1);
registrated1_gray = rgb2gray(registrated1);
figure();imshow(registrated1_gray);
fixed_2_gray = rgb2gray(fixed_rotate);
figure();imshow(fixed_2_gray);
%%%%%%%%%%%
M = zeros(256,1,'uint8'); % Store mapping - Cast to uint8 to respect data type
hist1 = imhist(registrated1_gray); % Compute histograms
hist2 = imhist(fixed_2_gray);
cdf1 = cumsum(hist1) / numel(registrated1_gray); %Compute CDFs
cdf2 = cumsum(hist2) / numel(fixed_2_gray);
% Compute the mapping
for idx = 1 : 256
[~,ind] = min(abs(cdf1(idx) - cdf2));
M(idx) = ind-1;
end
%Now apply the mapping to get first image to make
%the image look like the distribution of the second image
out = M(double(registrated1_gray)+1);
%%%%%%%%%%%%
b = histeq(registrated1_gray,imhist(fixed_2_gray));
[r1,c1] = size(b);
registrated1_1 = zeros(r1,c1);
registrated1_1 = uint8(registrated1_1*0);
for i = 1:size(b,1)
for j = 1:size(b,2)
if b(i,j, 1) >= 150
% Change from white to our gray level
registrated1_1 (i,j) = 0;
registrated1_1 (i,j) = 0;
registrated1_1 (i,j) = 0;
else
registrated1_1 (i,j) = 255;
registrated1_1 (i,j) = 255;
registrated1_1 (i,j) = 255;
end
end
end
%registrated1_1 = imfill(registrated1_1,'holes');
%mask of registrated image
BW2 = bwareaopen(registrated1_1, 120);
figure();imshow(BW2);
figure();imshow(registrated1_1);
%mask of hist(reference) image
[r2,c2] = size(fixed_2_gray);
mask_hist = zeros(r2,c2);
mask_hist = uint8(mask_hist*0);
for i = 1:size(fixed_2_gray,1)
for j = 1:size(fixed_2_gray,2)
if fixed_2_gray(i,j) >= 170
% Change from white to our gray level
mask_hist (i,j) = 0;
mask_hist (i,j) = 0;
mask_hist (i,j) = 0;
else
mask_hist (i,j) = 255;
mask_hist (i,j) = 255;
mask_hist (i,j) = 255;
end
end
end
%mask_hist = imfill(mask_hist,'holes');
BW_hist = bwareaopen(mask_hist, 2000);
figure();imshow(BW_hist);
figure();imshow(mask_hist);
BW_hist(8369:23100,65:5219) = 0;
%overlapped pixels(TP)
%BW2_X = ~(BW2);
TP = BW_hist.*BW2;
figure();imshow(TP);
TP_idx=TP==1;
TP_idx=sum(TP_idx(:))
%non-overlapping pixels - region of PAS image(FN)
FN = BW_hist - TP;
figure();imshow(FN);
FN_idx=FN==1;
FN_idx=sum(FN_idx(:))
%non-overlapping pixels - region of IF image(FP)
FP = BW2 - BW_hist;
figure();imshow(FP);
FP_idx=FP==1;
FP_idx=sum(FP_idx(:))
%common background - TN
TN = BW_hist + BW2;
figure();imshow(TN);
TN_idx=TN==0;
TN_idx_1=sum(TN_idx(:))
Sensitivity = TP_idx/(TP_idx+FN_idx)
Specificity = TN_idx_1/(FP_idx+TN_idx_1)
PPV = TP_idx/(TP_idx+FP_idx)
NPV = TN_idx_1/(TN_idx_1+FN_idx)
% for i = 1:size(registrated1,1)
% for j = 1:size(registrated1,2)
% if registrated1(i,j, 1) <= 60 && registrated1(i,j, 2) <= 60 && registrated1(i,j, 3) <= 60
% % Change from white to our gray level
% registrated1 (i,j, 1) = 240;
% registrated1 (i,j, 2) = 240;
% registrated1 (i,j, 3) = 240;
% end
% end
% end
% figure();imshow(registrated1);