-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpft_InterpolateImages.m
48 lines (32 loc) · 1.46 KB
/
pft_InterpolateImages.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
function [ W, M, S, P ] = pft_InterpolateImages(Wzor, Mask, Segmentation, Perimeter, OriginalResolution, InterpolationType)
% Extract the common (original) image size
[ MR, MC ] = size(Wzor);
% Re-assign values in the Segmentation image to make the interpolation and rounding more straightforward
Background = 0;
Blood = 1;
Myocardium = 2;
Heart = 4;
% The Other category is used here as a temporary swap value, to avoid the creation of interpolated pixels with a value of 3,
% since these would then be unassigned to a tissue type within the traditional "bit-binary" labelling scheme
Other = 3;
switch InterpolationType
case 'Imresize - (x4 x4) - cubic'
W = imresize(Wzor, 4, 'cubic');
M = imresize(Mask, 4, 'cubic');
Segmentation(Segmentation == Heart) = Other;
S = imresize(Segmentation, 4, 'cubic');
S(S == Other) = Heart;
P = imresize(Perimeter, 4, 'cubic');
case 'Imresize - 0.25 mm pixels - cubic'
NewPixelSize = 0.25;
Magnification = OriginalResolution/NewPixelSize;
NR = uint16(round(Magnification*MR));
NC = uint16(round(Magnification*MC));
W = imresize(Wzor, [NR, NC], 'cubic');
M = imresize(Mask, [NR, NC], 'cubic');
Segmentation(Segmentation == Heart) = Other;
S = imresize(Segmentation, [NR, NC], 'cubic');
S(S == Other) = Heart;
P = imresize(Perimeter, [NR, NC], 'cubic');
end
end