-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_ConnComponents.m
More file actions
60 lines (54 loc) · 2.25 KB
/
Copy pathplot_ConnComponents.m
File metadata and controls
60 lines (54 loc) · 2.25 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
function plot_ConnComponents(metrics, grainsVar, connectedGrains, imgSampPath, samp_name, methodName)
% Plot connected components analysis
% Component size distribution (size = number of grains)
counts = histcounts(metrics.compSizes, 'BinMethod', 'integers');
figure;
histogram(metrics.compSizes, 'BinMethod', 'integers', 'FaceColor', [0.8 0.3 0.6]);
xlabel('Number of Grains');
ylabel('Number of Components');
ylim([0 max(counts) * 1.1]);
title('Connected Component Sizes');
set(gcf, 'color', 'w');
PrettyPlotsSingle
export_fig(char(fullfile(imgSampPath, sprintf('%s_connComps_sizedist_%s.png', samp_name, methodName))), '-m2');
close
% Compoent area distribution
binWidth = max(metrics.componentAreas)/15; % Divide range into 15 bins >> adjust if desired
figure;
h = histogram(metrics.componentAreas,'BinWidth', binWidth, 'FaceColor', [0.6 0.3 0.8]);
xlabel('Component Area');
ylabel('Number of Components');
xlim([0 max(metrics.componentAreas)*1.05])
ylim([0 max(h.Values) * 1.1])
title('Connected Component Areas');
set(gcf, 'color', 'w');
PrettyPlotsSingle
export_fig(char(fullfile(imgSampPath, sprintf('%s_connComps_areaDist_%s.png', samp_name, methodName))), '-m2');
close
% Component area map
figure;
plot(grainsVar, metrics.componentAreasPerGrain);
hold on;
plot(grainsVar.boundary, 'linewidth', 0.5);
hold on;
plot(connectedGrains.boundary,'linecolor','k','linewidth',2,'linestyle', '-')
title('Components Colored by Cluster Area');
colormap(parula);
mtexColorbar('title', 'area (um^2)');
hold off;
export_fig(char(fullfile(imgSampPath, sprintf('%s_connComps_areaGrains_%s.png', samp_name, methodName))), '-m2');
close
% Component size map
figure;
plot(grainsVar, metrics.componentSizesPerGrain);
hold on;
plot(grainsVar.boundary, 'linewidth', 0.5);
hold on;
plot(connectedGrains.boundary,'linecolor','k','linewidth',2,'linestyle', '-')
title('Components Colored by Cluster Size');
colormap(parula);
mtexColorbar('title', 'number of grains');
hold off;
export_fig(char(fullfile(imgSampPath, sprintf('%s_connComps_sizeGrains_%s.png', samp_name, methodName))), '-m2');
close
end