-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcast_iron_tomo_phases.m
More file actions
159 lines (126 loc) · 3.28 KB
/
Copy pathcast_iron_tomo_phases.m
File metadata and controls
159 lines (126 loc) · 3.28 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
clear
close all
%%
imstart =1;
imend=505;
for i = imstart:imend
data(:,:, i-imstart+1) = im2double(imread( ...
strcat('C:\Users\la3314de\Downloads\Group1\Group1\Group1_tomo-A_recon_Export_', num2str(i,'%04d'), '.tiff')));
end
%%
% extract and plot slices through volume
slice1(:,:) = data(50,:,:);
slice2(:,:) = data(:,100,:);
slice3(:,:) = data(:,:,200);
figure(1)
% Create a layout grid: 1 row, 3 columns
t = tiledlayout(1,3);
t.TileSpacing = 'compact';
t.Padding = 'compact';
% --- Slice 1 ---
nexttile
pcolor(slice1')
shading flat
daspect([1 1 1])
clim([0 1]) % Locks color range (0=Black, 1=White)
title('XZ')
% --- Slice 2 ---
nexttile
pcolor(slice2')
shading flat
daspect([1 1 1])
clim([0 1]) % Locks color range
title('YZ')
% --- Slice 3 ---
nexttile
pcolor(slice3')
shading flat
daspect([1 1 1])
clim([0 1]) % Locks color range
title('XY')
% --- Shared Settings ---
colormap(hot)
% Add the shared colorbar to the layout (puts it on the right)
cb = colorbar;
cb.Layout.Tile = 'east';
cb.Label.String = 'Phase Presence (0=No, 1=Yes)';
%%
volumeViewer(data)
%%
% make histogram of grey-scale values to see different intensities
% plot histogram
figure(2)
histogram(data,1000)
% define yscale as logarithmic to see
%smaller peaks in histogram
set(gca,'YScale','log')
xlabel('Grey-scale value')
ylabel('Intensity (a.u)')
%% This is an image with zeros in the background and ones in the sample region
mask = data;
mask(mask>0.001) = 1;
mask = uint8(mask);
%% FIND THE REAL VALUES
% Pick a slice in the middle of your sample
mid_slice = data(:,:,100);
% Open a tool to inspect pixel values
figure(99)
imshow(mid_slice, []) % Display with auto-scaling
title('HOVER over material to see values ->')
impixelinfo; % <--- This adds a tool at the bottom left
%% THRESHOLDS
threshold_high = 0.82;
threshold_low= 0.5055; % 0.5405;
%% MASKS
mask_high = data > threshold_high;
mask_med = data > threshold_low & data <= threshold_high;
mask_low = data < threshold_low & (mask == 1);
mask_study = data > 0.5055;
% Uncomment which one is needed to be analyzed
%bin = mask_high; % For bright pieces
bin = mask_med; % For main material
%bin = mask_low; % For "pores"
%bin = mask_study;
% change format to uint8, which makes some things easier later on
bin = uint8(bin);
%% 3D view of bin
CC = bwconncomp(bin);
L = labelmatrix(CC);
volumeViewer(L)
%%
% extract and plot slices through volume
slice1(:,:) = bin(50,:,:);
slice2(:,:) = bin(:,100,:);
slice3(:,:) = bin(:,:,200);
figure(4)
% Create a layout grid: 1 row, 3 columns
t = tiledlayout(1,3);
t.TileSpacing = 'compact';
t.Padding = 'compact';
% --- Slice 1 ---
nexttile
pcolor(slice1')
shading flat
daspect([1 1 1])
clim([0 1]) % Locks color range (0=Black, 1=White)
title('XZ')
% --- Slice 2 ---
nexttile
pcolor(slice2')
shading flat
daspect([1 1 1])
clim([0 1]) % Locks color range
title('YZ')
% --- Slice 3 ---
nexttile
pcolor(slice3')
shading flat
daspect([1 1 1])
clim([0 1]) % Locks color range
title('XY')
% --- Shared Settings ---
colormap(hot)
% Add the shared colorbar to the layout (puts it on the right)
cb = colorbar;
cb.Layout.Tile = 'east';
cb.Label.String = 'Phase Presence (0=No, 1=Yes)';