Datasets:
Languages:
English
Size:
n<1K
Tags:
pool-boiling
two-phase-flow
thermal-management
bubble-morphology
unsupervised-learning
principal-component-analysis
License:
Add files using upload-large-folder tool
Browse files- DataProcessTools/Conventional_descriptors/bubbleStat_calculator_v4.m +158 -0
- DataProcessTools/Conventional_descriptors/bubbles_annotator_v6.m +230 -0
- DataProcessTools/Generalized_descriptors/PC_calculator_v4.m +116 -0
- DataProcessTools/Generalized_descriptors/dominantDescriptor_calculator_v4.m +124 -0
- FCu-H2O/annotatedBubbles/FCu-H2O-BubbleContours.json +0 -0
- FCu-H2O/annotatedBubbles/FCu-H2O_100W_00030.jpg +3 -0
- FCu-H2O/annotatedBubbles/FCu-H2O_100W_00140.jpg +3 -0
- FCu-H2O/annotatedBubbles/FCu-H2O_60W_01670.jpg +3 -0
- FCu-H2O/annotatedBubbles/FCu-H2O_60W_02220.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O-BubbleContours.json +0 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_130W_02400.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_130W_02700.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_130W_02750.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_00750.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_00900.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_01200.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_01500.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_01800.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_02100.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_02400.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_02700.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_02750.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_40W_03000.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_00000.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_00300.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_00600.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_00750.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_00900.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_01200.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_01500.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_01800.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_02100.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_02400.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_02700.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_02750.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_60W_03000.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_00000.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_00300.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_00600.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_00750.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_00900.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_01200.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_01500.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_01800.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_02100.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_02400.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_02700.jpg +3 -0
- PCu-H2O/annotatedBubbles/PCu-H2O_90W_02750.jpg +3 -0
- PSi-HFE/annotatedBubbles/PSi-HFE-BubbleContours.json +0 -0
- SSi-HFE/annotatedBubbles/SSi-HFE-BubbleContours.json +0 -0
DataProcessTools/Conventional_descriptors/bubbleStat_calculator_v4.m
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% CALCULATE BUBBLE STATISTICS FROM JSON DATA
|
| 2 |
+
%{
|
| 3 |
+
Description:
|
| 4 |
+
This script reads a JSON file containing manually annotated bubble contours.
|
| 5 |
+
It then calculates key bubble statistics for each image, aggregates the
|
| 6 |
+
results by heat load, and computes the mean and standard deviation for
|
| 7 |
+
each heat load condition.
|
| 8 |
+
|
| 9 |
+
Instructions:
|
| 10 |
+
0. Define the pixel resolution parameter (l_px) accordingly.
|
| 11 |
+
1. Run this script.
|
| 12 |
+
2. A dialog will prompt you to select the JSON data file.
|
| 13 |
+
3. A second dialog will prompt you to select the folder containing the
|
| 14 |
+
corresponding original images.
|
| 15 |
+
4. The script will process the data and display a results table in the
|
| 16 |
+
Command Window.
|
| 17 |
+
5. (Optional) Set `save_contour_Mode` to true to save annotated images.
|
| 18 |
+
|
| 19 |
+
Last modified: 2025/10/08
|
| 20 |
+
Author: Lige Zhang
|
| 21 |
+
Reference: International Journal of Heat and Mass Transfer 255 (2026): 127894.
|
| 22 |
+
%}
|
| 23 |
+
clear; close all; clc
|
| 24 |
+
format long
|
| 25 |
+
|
| 26 |
+
%% --------------------- USER SETTINGS ---------------------
|
| 27 |
+
% --- Set to true to save images with contours drawn on them ---
|
| 28 |
+
save_contour_Mode = true;
|
| 29 |
+
|
| 30 |
+
% --- Physical Constants ---
|
| 31 |
+
% l_px = 32.26e-3; % Pixel resolution in [mm/pixel] <- IMPORTANT: need to be updated accroding to the dataset!
|
| 32 |
+
l_px = 31.25e-3;
|
| 33 |
+
A_px = l_px^2; % Area of a single pixel in [mm^2/pixel]
|
| 34 |
+
|
| 35 |
+
%% --------------------- DATA LOADING ---------------------
|
| 36 |
+
[jsonFileName, jsonPath] = uigetfile('*.json', 'Select the annotated JSON file');
|
| 37 |
+
if isequal(jsonFileName, 0), disp('File selection cancelled.'); return; end
|
| 38 |
+
jsonFile = fullfile(jsonPath, jsonFileName);
|
| 39 |
+
|
| 40 |
+
imageFolderDIR = uigetdir(jsonPath, 'Select the folder containing the original images');
|
| 41 |
+
if isequal(imageFolderDIR, 0), disp('Folder selection cancelled.'); return; end
|
| 42 |
+
|
| 43 |
+
jsonText = fileread(jsonFile);
|
| 44 |
+
structData = jsondecode(jsonText);
|
| 45 |
+
imageDataNames = fieldnames(structData);
|
| 46 |
+
|
| 47 |
+
%% ----------------- BUBBLE STATISTICS CALCULATION -----------------
|
| 48 |
+
bubbleStat = struct;
|
| 49 |
+
disp('Processing images and calculating statistics...');
|
| 50 |
+
|
| 51 |
+
% --- Create the output directory for contour images ---
|
| 52 |
+
if save_contour_Mode == true
|
| 53 |
+
save_contour_DIR = fullfile(imageFolderDIR, "BubbleContours");
|
| 54 |
+
if ~exist(save_contour_DIR, 'dir'), mkdir(save_contour_DIR); end
|
| 55 |
+
end
|
| 56 |
+
|
| 57 |
+
for i = 1:length(imageDataNames)
|
| 58 |
+
currentImageKey = imageDataNames{i};
|
| 59 |
+
currentImageData = structData.(currentImageKey);
|
| 60 |
+
imageFileName = currentImageData.FileName;
|
| 61 |
+
|
| 62 |
+
heatLoadToken = regexp(imageFileName, '_(\d+(\.\d+)?W)_', 'tokens');
|
| 63 |
+
if isempty(heatLoadToken)
|
| 64 |
+
warning('Could not parse heat load from filename: %s. Skipping.', imageFileName);
|
| 65 |
+
continue;
|
| 66 |
+
end
|
| 67 |
+
heatLoadStr = heatLoadToken{1}{1};
|
| 68 |
+
heatLoadFieldName = matlab.lang.makeValidName(['load_' heatLoadStr]);
|
| 69 |
+
|
| 70 |
+
bubbles = currentImageData.Bubbles;
|
| 71 |
+
bubbleNames = fieldnames(bubbles);
|
| 72 |
+
numOfBubbles_i = length(bubbleNames);
|
| 73 |
+
|
| 74 |
+
if numOfBubbles_i == 0, continue; end
|
| 75 |
+
|
| 76 |
+
allBubbleAreas_i = zeros(numOfBubbles_i, 1);
|
| 77 |
+
for j = 1:numOfBubbles_i
|
| 78 |
+
bubbleName = bubbleNames{j};
|
| 79 |
+
x_coord = bubbles.(bubbleName).x_coordinate;
|
| 80 |
+
y_coord = bubbles.(bubbleName).y_coordinate;
|
| 81 |
+
allBubbleAreas_i(j) = polyarea(x_coord, y_coord) * A_px;
|
| 82 |
+
end
|
| 83 |
+
|
| 84 |
+
sumAreaBubbles_i = sum(allBubbleAreas_i);
|
| 85 |
+
avgBubbleArea_i = mean(allBubbleAreas_i);
|
| 86 |
+
avgBubbleRadius_i = sqrt(avgBubbleArea_i / pi);
|
| 87 |
+
|
| 88 |
+
Img_proc = imread(fullfile(imageFolderDIR, imageFileName));
|
| 89 |
+
imageTotalArea = size(Img_proc, 1) * size(Img_proc, 2) * A_px;
|
| 90 |
+
vaporAreaFraction_i = sumAreaBubbles_i / imageTotalArea;
|
| 91 |
+
|
| 92 |
+
if ~isfield(bubbleStat, heatLoadFieldName)
|
| 93 |
+
bubbleStat.(heatLoadFieldName).NumBubbles = [];
|
| 94 |
+
bubbleStat.(heatLoadFieldName).AvgArea = [];
|
| 95 |
+
bubbleStat.(heatLoadFieldName).AvgRadius = [];
|
| 96 |
+
bubbleStat.(heatLoadFieldName).VaporFraction = [];
|
| 97 |
+
end
|
| 98 |
+
|
| 99 |
+
bubbleStat.(heatLoadFieldName).NumBubbles(end+1) = numOfBubbles_i;
|
| 100 |
+
bubbleStat.(heatLoadFieldName).AvgArea(end+1) = avgBubbleArea_i;
|
| 101 |
+
bubbleStat.(heatLoadFieldName).AvgRadius(end+1) = avgBubbleRadius_i;
|
| 102 |
+
bubbleStat.(heatLoadFieldName).VaporFraction(end+1) = vaporAreaFraction_i;
|
| 103 |
+
|
| 104 |
+
%% --- CORRECTED: Save tightly-cropped image with sanitized filename ---
|
| 105 |
+
if save_contour_Mode == true
|
| 106 |
+
% Create a figure but keep it invisible for faster processing
|
| 107 |
+
fig = figure('Visible', 'off');
|
| 108 |
+
ax = axes(fig); % Create axes in the figure
|
| 109 |
+
imshow(Img_proc, 'Parent', ax);
|
| 110 |
+
hold(ax, 'on');
|
| 111 |
+
for j = 1:numOfBubbles_i
|
| 112 |
+
bubbleName = bubbleNames{j};
|
| 113 |
+
plot(ax, bubbles.(bubbleName).x_coordinate, bubbles.(bubbleName).y_coordinate, 'r--', 'LineWidth', 2);
|
| 114 |
+
end
|
| 115 |
+
hold(ax, 'off');
|
| 116 |
+
|
| 117 |
+
% --- FIX 1: Sanitize filename to handle '.' correctly ---
|
| 118 |
+
[~, base_name, ~] = fileparts(imageFileName);
|
| 119 |
+
sanitized_name = strrep(base_name, '.', 'd');
|
| 120 |
+
output_image_path = fullfile(save_contour_DIR, [sanitized_name, '.png']);
|
| 121 |
+
|
| 122 |
+
% --- FIX 2: Use exportgraphics to save without whitespace ---
|
| 123 |
+
exportgraphics(ax, output_image_path, 'Resolution', 150);
|
| 124 |
+
|
| 125 |
+
close(fig);
|
| 126 |
+
end
|
| 127 |
+
end
|
| 128 |
+
|
| 129 |
+
disp('Calculation finished. Summarizing results...');
|
| 130 |
+
%% ------------------- FINAL RESULTS SUMMARY -------------------
|
| 131 |
+
loadNames = fieldnames(bubbleStat);
|
| 132 |
+
numLoads = length(loadNames);
|
| 133 |
+
|
| 134 |
+
resultsData = zeros(numLoads, 9);
|
| 135 |
+
for k = 1:numLoads
|
| 136 |
+
loadName = loadNames{k};
|
| 137 |
+
loadValueStr = regexp(loadName, '\d+(\.?\d+)?', 'match');
|
| 138 |
+
loadValue = str2double(loadValueStr{1});
|
| 139 |
+
|
| 140 |
+
resultsData(k, :) = [
|
| 141 |
+
loadValue, ...
|
| 142 |
+
mean(bubbleStat.(loadName).NumBubbles), std(bubbleStat.(loadName).NumBubbles), ...
|
| 143 |
+
mean(bubbleStat.(loadName).AvgArea), std(bubbleStat.(loadName).AvgArea), ...
|
| 144 |
+
mean(bubbleStat.(loadName).AvgRadius), std(bubbleStat.(loadName).AvgRadius), ...
|
| 145 |
+
mean(bubbleStat.(loadName).VaporFraction), std(bubbleStat.(loadName).VaporFraction)
|
| 146 |
+
];
|
| 147 |
+
end
|
| 148 |
+
|
| 149 |
+
resultsData = sortrows(resultsData, 1);
|
| 150 |
+
resultsTable = array2table(resultsData, 'VariableNames', {
|
| 151 |
+
'HeatLoad_W', ...
|
| 152 |
+
'Mean_NumBubbles', 'StdDev_NumBubbles', ...
|
| 153 |
+
'Mean_AvgArea_mm2', 'StdDev_AvgArea_mm2', ...
|
| 154 |
+
'Mean_AvgRadius_mm', 'StdDev_AvgRadius_mm', ...
|
| 155 |
+
'Mean_VaporFraction', 'StdDev_VaporFraction'
|
| 156 |
+
});
|
| 157 |
+
|
| 158 |
+
disp(resultsTable);
|
DataProcessTools/Conventional_descriptors/bubbles_annotator_v6.m
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% bubbles_annotator
|
| 2 |
+
%{
|
| 3 |
+
Version: v6
|
| 4 |
+
Description:
|
| 5 |
+
This script provides a user interface to manually draw bubble contours on a
|
| 6 |
+
sequence of images. It allows the user to define regions of interest (ROIs)
|
| 7 |
+
interactively. The contour data for all processed images is then aggregated
|
| 8 |
+
and can be exported to a single, structured JSON file.
|
| 9 |
+
|
| 10 |
+
Instructions:
|
| 11 |
+
1. Run this script in MATLAB.
|
| 12 |
+
2. A dialog will appear. Select the folder containing your images.
|
| 13 |
+
3. For each image, a figure window will open.
|
| 14 |
+
- Left-click to place the vertices of a polygon around a bubble.
|
| 15 |
+
- Keyboard backspace to undo a click point.
|
| 16 |
+
- Double-click to finalize the shape. The bubble will be drawn in red.
|
| 17 |
+
4. After each bubble, a dialog will ask for your next action.
|
| 18 |
+
- 'Define more': Draw another bubble on the same image.
|
| 19 |
+
- 'Redefine last bubble': Erase the last bubble you just drew.
|
| 20 |
+
- 'Reset all': Clear all bubbles on the current image and start over.
|
| 21 |
+
- 'Next image': Move to the next image in the folder.
|
| 22 |
+
- 'Stop defining': End the annotation session.
|
| 23 |
+
5. At the end, you will be prompted to save all collected data to a JSON file.
|
| 24 |
+
|
| 25 |
+
Last modified: 2025/10/08
|
| 26 |
+
Author: Lige Zhang
|
| 27 |
+
Reference: International Journal of Heat and Mass Transfer 255 (2026): 127894.
|
| 28 |
+
%}
|
| 29 |
+
%% ------------------- Setup -------------------
|
| 30 |
+
clear, clc
|
| 31 |
+
close all
|
| 32 |
+
format long
|
| 33 |
+
%% --------------------- SCRIPT INITIALIZATION ---------------------
|
| 34 |
+
% Let the user interactively select the folder containing the images
|
| 35 |
+
imageFolderDIR = uigetdir('', 'Select the folder containing your SOURCE images');
|
| 36 |
+
if imageFolderDIR == 0
|
| 37 |
+
disp('Source folder selection cancelled. Script terminated.');
|
| 38 |
+
return;
|
| 39 |
+
end
|
| 40 |
+
|
| 41 |
+
% --- Automatically create a subfolder for the images results ---
|
| 42 |
+
outputFolderDIR = fullfile(imageFolderDIR, 'annotated_results');
|
| 43 |
+
if ~exist(outputFolderDIR, 'dir')
|
| 44 |
+
mkdir(outputFolderDIR);
|
| 45 |
+
end
|
| 46 |
+
|
| 47 |
+
% User-configurable settings
|
| 48 |
+
img_type = '.jpg';
|
| 49 |
+
output_json_filename = 'bubble_labeled_data.json';
|
| 50 |
+
|
| 51 |
+
% Get a list of all image files of the specified type in the folder
|
| 52 |
+
im_files = dir(fullfile(imageFolderDIR, ['*' img_type]));
|
| 53 |
+
if isempty(im_files)
|
| 54 |
+
disp(['No images of type "' img_type '" found in the source folder.']);
|
| 55 |
+
return;
|
| 56 |
+
end
|
| 57 |
+
|
| 58 |
+
% Initialize a master struct to store data for all images
|
| 59 |
+
allFramesData = struct;
|
| 60 |
+
disp(['Found ' num2str(length(im_files)) ' images to process.']);
|
| 61 |
+
|
| 62 |
+
%% --------------------- MAIN PROCESSING LOOP ---------------------
|
| 63 |
+
for j = 1:length(im_files)
|
| 64 |
+
|
| 65 |
+
imageFileName = im_files(j).name;
|
| 66 |
+
|
| 67 |
+
% Create a custom, MATLAB-compatible struct field name
|
| 68 |
+
imageName = strrep(imageFileName, img_type, '');
|
| 69 |
+
imageName = strrep(imageName, '.', 'd');
|
| 70 |
+
imageName = strrep(imageName, '-', '');
|
| 71 |
+
if isstrprop(imageName(1), 'digit')
|
| 72 |
+
imageName = ['Image' imageName];
|
| 73 |
+
end
|
| 74 |
+
|
| 75 |
+
% Call the interactive drawing function for the current image
|
| 76 |
+
[stop_processing, imageBubblesData] = drawROI(imageFolderDIR, imageFileName);
|
| 77 |
+
|
| 78 |
+
% Store the data for the current image in the master struct
|
| 79 |
+
allFramesData.(imageName) = imageBubblesData;
|
| 80 |
+
|
| 81 |
+
% --- NEW: Save the annotated image ---
|
| 82 |
+
if ~isempty(fieldnames(imageBubblesData.Bubbles))
|
| 83 |
+
% Load the original image again
|
| 84 |
+
I = imread(fullfile(imageFolderDIR, imageFileName));
|
| 85 |
+
% Create a new figure, but keep it invisible
|
| 86 |
+
fig_to_save = figure('Visible', 'off');
|
| 87 |
+
imshow(I);
|
| 88 |
+
hold on;
|
| 89 |
+
|
| 90 |
+
% Get the names of the bubbles to draw
|
| 91 |
+
bubble_names = fieldnames(imageBubblesData.Bubbles);
|
| 92 |
+
for i = 1:length(bubble_names)
|
| 93 |
+
bubble_data = imageBubblesData.Bubbles.(bubble_names{i});
|
| 94 |
+
plot(bubble_data.x_coordinate, bubble_data.y_coordinate, 'r--', 'LineWidth', 2);
|
| 95 |
+
end
|
| 96 |
+
hold off;
|
| 97 |
+
|
| 98 |
+
% Save the figure to the selected output directory
|
| 99 |
+
output_image_path = fullfile(outputFolderDIR, imageFileName);
|
| 100 |
+
saveas(fig_to_save, output_image_path);
|
| 101 |
+
close(fig_to_save); % Close the invisible figure
|
| 102 |
+
end
|
| 103 |
+
|
| 104 |
+
% Display progress to the user
|
| 105 |
+
remaining = length(im_files) - j;
|
| 106 |
+
disp(['Number of images remaining to process: ' num2str(remaining)])
|
| 107 |
+
|
| 108 |
+
if stop_processing
|
| 109 |
+
disp('User stopped the process.');
|
| 110 |
+
break
|
| 111 |
+
end
|
| 112 |
+
end
|
| 113 |
+
|
| 114 |
+
%% --------------------- EXPORT TO JSON FILE ---------------------
|
| 115 |
+
if ~isempty(fieldnames(allFramesData))
|
| 116 |
+
jsonText = jsonencode(allFramesData, "PrettyPrint", true);
|
| 117 |
+
|
| 118 |
+
promptMessage = 'Save the collected bubble data to a JSON file?';
|
| 119 |
+
titleBarCaption = 'Export Data';
|
| 120 |
+
button = questdlg(promptMessage, titleBarCaption, 'Save', 'Do Not Save', 'Save');
|
| 121 |
+
|
| 122 |
+
if strcmpi(button, 'Save')
|
| 123 |
+
% --- CHANGE: Save JSON to the selected output directory ---
|
| 124 |
+
json_output_path = fullfile(outputFolderDIR, output_json_filename);
|
| 125 |
+
fileID = fopen(json_output_path, 'w');
|
| 126 |
+
fprintf(fileID, jsonText);
|
| 127 |
+
fclose(fileID);
|
| 128 |
+
disp(['Data successfully saved to: ' json_output_path]);
|
| 129 |
+
else
|
| 130 |
+
disp('Data not saved.');
|
| 131 |
+
end
|
| 132 |
+
end
|
| 133 |
+
|
| 134 |
+
disp('Annotation process finished.');
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
%% #################### LOCAL FUNCTION: drawROI (Unchanged) ####################
|
| 138 |
+
function [stop_define, imageBubblesData] = drawROI(imageFolderDIR, imageFileName)
|
| 139 |
+
|
| 140 |
+
stop_define = false;
|
| 141 |
+
ImageFile = fullfile(imageFolderDIR, imageFileName);
|
| 142 |
+
|
| 143 |
+
I = imread(ImageFile);
|
| 144 |
+
if size(I, 3) == 3
|
| 145 |
+
I = rgb2gray(I);
|
| 146 |
+
end
|
| 147 |
+
|
| 148 |
+
regionsOfInterests = struct;
|
| 149 |
+
|
| 150 |
+
fig = figure(1);
|
| 151 |
+
imshow(I);
|
| 152 |
+
title({imageFileName, 'Left-click to draw; Keyboard backspace to undo a click point; Double-click to finish a bubble.'}, 'Interpreter', 'none');
|
| 153 |
+
hold on;
|
| 154 |
+
|
| 155 |
+
while true
|
| 156 |
+
roi = drawpolygon('Color','g');
|
| 157 |
+
|
| 158 |
+
xi = round(roi.Position(:,1));
|
| 159 |
+
yi = round(roi.Position(:,2));
|
| 160 |
+
|
| 161 |
+
plot(xi, yi, 'r--', 'LineWidth', 2);
|
| 162 |
+
|
| 163 |
+
num_regions = length(fieldnames(regionsOfInterests)) + 1;
|
| 164 |
+
bubble_name = ['b' sprintf('%04d', num_regions)];
|
| 165 |
+
bubble_data = struct('x_coordinate', xi, 'y_coordinate', yi);
|
| 166 |
+
regionsOfInterests.(bubble_name) = bubble_data;
|
| 167 |
+
|
| 168 |
+
promptMessage = 'What to do next?';
|
| 169 |
+
titleBarCaption = 'Action';
|
| 170 |
+
choices = {'Define more', 'Redefine last bubble', 'Reset all', 'Next image', 'Stop defining'};
|
| 171 |
+
|
| 172 |
+
[indx, tf] = listdlg('PromptString', promptMessage, ...
|
| 173 |
+
'SelectionMode', 'single', ...
|
| 174 |
+
'ListString', choices, ...
|
| 175 |
+
'Name', titleBarCaption, ...
|
| 176 |
+
'ListSize', [250, 120]);
|
| 177 |
+
|
| 178 |
+
if ~tf
|
| 179 |
+
choice = 'Next image';
|
| 180 |
+
else
|
| 181 |
+
choice = choices{indx};
|
| 182 |
+
end
|
| 183 |
+
|
| 184 |
+
switch choice
|
| 185 |
+
case 'Define more'
|
| 186 |
+
continue;
|
| 187 |
+
|
| 188 |
+
case 'Redefine last bubble'
|
| 189 |
+
disp('Removing the last drawn bubble.');
|
| 190 |
+
bubble_names = fieldnames(regionsOfInterests);
|
| 191 |
+
if ~isempty(bubble_names)
|
| 192 |
+
last_bubble_name = bubble_names{end};
|
| 193 |
+
regionsOfInterests = rmfield(regionsOfInterests, last_bubble_name);
|
| 194 |
+
cla;
|
| 195 |
+
imshow(I);
|
| 196 |
+
title({imageFileName, 'REDEFINE LAST: Left-click to draw, Double-click to finish.'}, 'Interpreter', 'none');
|
| 197 |
+
hold on;
|
| 198 |
+
remaining_bubble_names = fieldnames(regionsOfInterests);
|
| 199 |
+
for i = 1:length(remaining_bubble_names)
|
| 200 |
+
bubble_data = regionsOfInterests.(remaining_bubble_names{i});
|
| 201 |
+
plot(bubble_data.x_coordinate, bubble_data.y_coordinate, 'r--', 'LineWidth', 2);
|
| 202 |
+
end
|
| 203 |
+
else
|
| 204 |
+
disp('No bubbles to redefine.');
|
| 205 |
+
end
|
| 206 |
+
continue;
|
| 207 |
+
|
| 208 |
+
case 'Reset all'
|
| 209 |
+
disp('Clearing all bubbles for this image. Please start again.');
|
| 210 |
+
regionsOfInterests = struct;
|
| 211 |
+
cla;
|
| 212 |
+
imshow(I);
|
| 213 |
+
title({imageFileName, 'RESET: Left-click to draw, Double-click to finish.'}, 'Interpreter', 'none');
|
| 214 |
+
continue;
|
| 215 |
+
|
| 216 |
+
case 'Next image'
|
| 217 |
+
break;
|
| 218 |
+
|
| 219 |
+
case 'Stop defining'
|
| 220 |
+
stop_define = true;
|
| 221 |
+
break;
|
| 222 |
+
end
|
| 223 |
+
end
|
| 224 |
+
|
| 225 |
+
close(fig);
|
| 226 |
+
|
| 227 |
+
imageBubblesData = struct;
|
| 228 |
+
imageBubblesData.FileName = imageFileName;
|
| 229 |
+
imageBubblesData.Bubbles = regionsOfInterests;
|
| 230 |
+
end
|
DataProcessTools/Generalized_descriptors/PC_calculator_v4.m
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% PC_calculator
|
| 2 |
+
%{
|
| 3 |
+
Version: v4
|
| 4 |
+
Description: This code calculate PCs from image data of different heat
|
| 5 |
+
loads.
|
| 6 |
+
Last modified: 2025/10/07
|
| 7 |
+
Author: Lige Zhang
|
| 8 |
+
Reference: International Journal of Heat and Mass Transfer 255 (2026): 127894.
|
| 9 |
+
%}
|
| 10 |
+
%% ------------------- Setup -------------------
|
| 11 |
+
clear; clc; close all;
|
| 12 |
+
format long;
|
| 13 |
+
%% ------------------- Configuration -------------------
|
| 14 |
+
% Define the main data directory where high-speed images are stored.
|
| 15 |
+
MainData_DIR = "\path\to\your\data"; % <-- IMPORTANT: Set your actual data path here
|
| 16 |
+
|
| 17 |
+
% Define subfolders for each heat load
|
| 18 |
+
heatLoads = ["15W", "30W"];
|
| 19 |
+
|
| 20 |
+
% Create a main directory for saving results
|
| 21 |
+
outputDir = fullfile(MainData_DIR, "PC_Results");
|
| 22 |
+
if ~exist(outputDir, 'dir')
|
| 23 |
+
mkdir(outputDir);
|
| 24 |
+
end
|
| 25 |
+
|
| 26 |
+
% --- Parameters to define for PCA calculation ---
|
| 27 |
+
totalImages = 3000; % Total number of images to process per heat load (N)
|
| 28 |
+
imageFileFormat = '%05d.jpg'; % The file name format that the high speed images are saved.
|
| 29 |
+
numSubsets = 10; % Number of subsets to divide the data into
|
| 30 |
+
numPCs = 10; % Number of principal components to calculate and save
|
| 31 |
+
savePCdata = true; % Set to true to save results, false to just run
|
| 32 |
+
|
| 33 |
+
fprintf('PCA Calculation Started...\n');
|
| 34 |
+
|
| 35 |
+
%% ------------------- Main Processing Loop -------------------
|
| 36 |
+
% Loop over each heat load condition
|
| 37 |
+
for i = 1:length(heatLoads)
|
| 38 |
+
currentHeatLoad = heatLoads(i);
|
| 39 |
+
imageDataDir = fullfile(MainData_DIR, currentHeatLoad);
|
| 40 |
+
fprintf('\nProcessing Heat Load: %s\n', currentHeatLoad);
|
| 41 |
+
|
| 42 |
+
% Create a specific output folder for this heat load's results
|
| 43 |
+
heatLoadOutputDir = fullfile(outputDir, currentHeatLoad);
|
| 44 |
+
if ~exist(heatLoadOutputDir, 'dir')
|
| 45 |
+
mkdir(heatLoadOutputDir);
|
| 46 |
+
end
|
| 47 |
+
|
| 48 |
+
imagesPerSubset = totalImages / numSubsets; % (n)
|
| 49 |
+
|
| 50 |
+
% Loop over each of the 10 subsets
|
| 51 |
+
for s = 1:numSubsets
|
| 52 |
+
fprintf(' Calculating for Subset %d/%d...\n', s, numSubsets);
|
| 53 |
+
|
| 54 |
+
% --- 1. Load, Resize, and Vectorize Images for the Subset ---
|
| 55 |
+
|
| 56 |
+
% Determine the first and last image index for the current subset
|
| 57 |
+
firstImageIdx = (s - 1) * imagesPerSubset;
|
| 58 |
+
lastImageIdx = s * imagesPerSubset - 1;
|
| 59 |
+
|
| 60 |
+
% Pre-allocate matrix to hold image data for efficiency
|
| 61 |
+
% First, read one image to get its dimensions after resizing
|
| 62 |
+
sampleImPath = fullfile(imageDataDir, sprintf(imageFileFormat, firstImageIdx));
|
| 63 |
+
I_sample = imread(sampleImPath);
|
| 64 |
+
|
| 65 |
+
[m, n] = size(I_sample); % Get dimensions of the image
|
| 66 |
+
|
| 67 |
+
% Now pre-allocate the data matrix: p-by-n (pixels-by-images)
|
| 68 |
+
imageData = zeros(m * n, imagesPerSubset);
|
| 69 |
+
|
| 70 |
+
% Load all images for the current subset
|
| 71 |
+
for k = 1:imagesPerSubset
|
| 72 |
+
imgIndex = firstImageIdx + (k - 1);
|
| 73 |
+
imFile = sprintf(imageFileFormat, imgIndex);
|
| 74 |
+
|
| 75 |
+
% Read, convert to double for math, and resize
|
| 76 |
+
I = double(imread(fullfile(imageDataDir, imFile)));
|
| 77 |
+
% I_resized = imresize(I, 0.1);
|
| 78 |
+
|
| 79 |
+
% Normalize (0-255 -> 0-1) and flatten into a column vector
|
| 80 |
+
imageData(:, k) = reshape(I / 255.0, [m * n, 1]);
|
| 81 |
+
end
|
| 82 |
+
|
| 83 |
+
% --- 2. Perform PCA using SVD ---
|
| 84 |
+
|
| 85 |
+
% Calculate the mean image (vector) of the subset
|
| 86 |
+
meanImageVector = mean(imageData, 2);
|
| 87 |
+
|
| 88 |
+
% Subtract the mean from every image (mean-centering)
|
| 89 |
+
meanCenteredData = imageData - meanImageVector;
|
| 90 |
+
|
| 91 |
+
% Perform SVD on the transpose of the mean-centered data
|
| 92 |
+
% 'econ' is crucial for efficiency, as it calculates the "economy size" SVD
|
| 93 |
+
[U, S, V] = svd(meanCenteredData', 'econ');
|
| 94 |
+
|
| 95 |
+
% --- 3. Calculate and Save Principal Component Scores ---
|
| 96 |
+
|
| 97 |
+
% The PC scores are simply U*S.
|
| 98 |
+
|
| 99 |
+
all_PC_scores = U * S;
|
| 100 |
+
|
| 101 |
+
% Extract the first 10 PCs
|
| 102 |
+
PC_scores_to_save = all_PC_scores(:, 1:numPCs);
|
| 103 |
+
|
| 104 |
+
% Save the results to a CSV file if requested
|
| 105 |
+
if savePCdata
|
| 106 |
+
% Define a descriptive filename
|
| 107 |
+
fileName = sprintf('Subset_%02d_PCs.csv', s);
|
| 108 |
+
csvFilePath = fullfile(heatLoadOutputDir, fileName);
|
| 109 |
+
|
| 110 |
+
% Write the matrix of PC scores to the file
|
| 111 |
+
writematrix(PC_scores_to_save, csvFilePath);
|
| 112 |
+
end
|
| 113 |
+
end
|
| 114 |
+
end
|
| 115 |
+
|
| 116 |
+
fprintf('\nPCA Calculation Complete. Results saved in: %s\n', outputDir);
|
DataProcessTools/Generalized_descriptors/dominantDescriptor_calculator_v4.m
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%% dominantDescriptor_calculator
|
| 2 |
+
%{
|
| 3 |
+
Version: v4
|
| 4 |
+
Description: This code calculate dominant frequency and amplitude from PCs
|
| 5 |
+
of different heat loads.
|
| 6 |
+
Last modified: 2025/10/07
|
| 7 |
+
Author: Lige Zhang
|
| 8 |
+
Reference: International Journal of Heat and Mass Transfer 255 (2026): 127894.
|
| 9 |
+
%}
|
| 10 |
+
%% ------------------- Setup -------------------
|
| 11 |
+
clear; clc; close all;
|
| 12 |
+
format long;
|
| 13 |
+
|
| 14 |
+
%% ------------------- Configuration -------------------
|
| 15 |
+
% Define the main directory where the "PC_Results" folder is located.
|
| 16 |
+
MainData_DIR = "\path\to\your\data"; % <-- IMPORTANT: Set your path here
|
| 17 |
+
|
| 18 |
+
% Define subfolders for each heat load
|
| 19 |
+
heatLoads = ["15W", "30W", "60W", "100W", "150W", "200W", "220W"];
|
| 20 |
+
|
| 21 |
+
% --- Analysis Parameters ---
|
| 22 |
+
frameRate = 3000; % Frame rate of the video camera in Hz (fps)
|
| 23 |
+
numSubsets = 10; % The number of subsets for each heat load
|
| 24 |
+
pcToAnalyze = 1; % Which Principal Component to analyze.
|
| 25 |
+
|
| 26 |
+
% --- Input/Output Directories ---
|
| 27 |
+
% Pointing to the folder created by the PC_calculator script
|
| 28 |
+
pcResultsDir = fullfile(MainData_DIR, "PC_Results");
|
| 29 |
+
|
| 30 |
+
% A new folder will be created to store the Da and Df results
|
| 31 |
+
descriptorDir = fullfile(MainData_DIR, "Dominant_Descriptors");
|
| 32 |
+
if ~exist(descriptorDir, 'dir')
|
| 33 |
+
mkdir(descriptorDir);
|
| 34 |
+
end
|
| 35 |
+
|
| 36 |
+
fprintf('Dominant Descriptor Calculation Started...\n');
|
| 37 |
+
|
| 38 |
+
%% ------------------- Main Processing Loop -------------------
|
| 39 |
+
% Loop over each heat load condition
|
| 40 |
+
for i = 1:length(heatLoads)
|
| 41 |
+
currentHeatLoad = heatLoads(i);
|
| 42 |
+
fprintf('\nProcessing Heat Load: %s\n', currentHeatLoad);
|
| 43 |
+
|
| 44 |
+
% This is the folder containing the PC data for the current heat load
|
| 45 |
+
heatLoadDataDir = fullfile(pcResultsDir, currentHeatLoad);
|
| 46 |
+
|
| 47 |
+
% Pre-allocate arrays to store results from the 10 subsets
|
| 48 |
+
Da_values = zeros(numSubsets, 1);
|
| 49 |
+
Df_values = zeros(numSubsets, 1);
|
| 50 |
+
|
| 51 |
+
% Loop over each of the 10 subsets for the current heat load
|
| 52 |
+
for s = 1:numSubsets
|
| 53 |
+
% --- 1. Load the PC data for the current subset ---
|
| 54 |
+
|
| 55 |
+
% Construct the correct filename that was saved by the previous script
|
| 56 |
+
pc_filename = sprintf('Subset_%02d_PCs.csv', s);
|
| 57 |
+
pc_filepath = fullfile(heatLoadDataDir, pc_filename);
|
| 58 |
+
|
| 59 |
+
% Check if the file exists before trying to read it
|
| 60 |
+
if ~exist(pc_filepath, 'file')
|
| 61 |
+
warning('File not found, skipping: %s', pc_filepath);
|
| 62 |
+
continue; % Skip to the next subset
|
| 63 |
+
end
|
| 64 |
+
|
| 65 |
+
all_PC_scores = readmatrix(pc_filepath);
|
| 66 |
+
|
| 67 |
+
% Extract the time series for the PC we want to analyze (e.g., PC1)
|
| 68 |
+
pc1_time_series = all_PC_scores(:, pcToAnalyze);
|
| 69 |
+
|
| 70 |
+
% --- 2. Perform FFT to get the frequency spectrum ---
|
| 71 |
+
|
| 72 |
+
N = length(pc1_time_series); % Number of data points (should be 300)
|
| 73 |
+
|
| 74 |
+
% Perform the Fast Fourier Transform
|
| 75 |
+
Y = fft(pc1_time_series);
|
| 76 |
+
|
| 77 |
+
% Calculate the single-sided amplitude spectrum
|
| 78 |
+
P2 = abs(Y / N);
|
| 79 |
+
P1 = P2(1:floor(N/2)+1);
|
| 80 |
+
P1(2:end-1) = 2 * P1(2:end-1);
|
| 81 |
+
|
| 82 |
+
% Define the frequency domain vector
|
| 83 |
+
frequencies = frameRate * (0:(N/2)) / N;
|
| 84 |
+
|
| 85 |
+
% --- 3. Find the Dominant Amplitude (Da) and Frequency (Df) ---
|
| 86 |
+
|
| 87 |
+
% Find the maximum peak in the amplitude spectrum and its index
|
| 88 |
+
[max_amplitude, index] = max(P1);
|
| 89 |
+
|
| 90 |
+
% Store the results for this subset
|
| 91 |
+
Da_values(s) = max_amplitude;
|
| 92 |
+
Df_values(s) = frequencies(index);
|
| 93 |
+
end
|
| 94 |
+
|
| 95 |
+
% --- 4. Calculate Statistics and Save Results ---
|
| 96 |
+
|
| 97 |
+
% Calculate the mean and standard deviation across the 10 subsets
|
| 98 |
+
Da_mean = mean(Da_values);
|
| 99 |
+
Da_std = std(Da_values);
|
| 100 |
+
Df_mean = mean(Df_values);
|
| 101 |
+
Df_std = std(Df_values);
|
| 102 |
+
|
| 103 |
+
% Create a clean, organized table for the results
|
| 104 |
+
resultsTable = table((1:numSubsets)', Da_values, Df_values, ...
|
| 105 |
+
'VariableNames', {'Subset', 'Dominant_Amplitude_Da', 'Dominant_Frequency_Df'});
|
| 106 |
+
|
| 107 |
+
% Create a summary table for the statistics
|
| 108 |
+
summaryTable = table(Da_mean, Da_std, Df_mean, Df_std, ...
|
| 109 |
+
'VariableNames', {'Mean_Da', 'Std_Dev_Da', 'Mean_Df', 'Std_Dev_Df'});
|
| 110 |
+
|
| 111 |
+
% Define a descriptive output filename
|
| 112 |
+
output_filename = sprintf('%s_DominantParams_PC%02d.csv', currentHeatLoad, pcToAnalyze);
|
| 113 |
+
output_filepath = fullfile(descriptorDir, output_filename);
|
| 114 |
+
|
| 115 |
+
% Write the detailed subset results to the CSV
|
| 116 |
+
writetable(resultsTable, output_filepath);
|
| 117 |
+
|
| 118 |
+
% Append the summary statistics to the same file
|
| 119 |
+
writetable(summaryTable, output_filepath, 'WriteMode', 'append', 'WriteVariableNames', true);
|
| 120 |
+
|
| 121 |
+
fprintf(' Done. Results for %s saved.\n', currentHeatLoad);
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
fprintf('\nDescriptor Calculation Complete. Results saved in: %s\n', descriptorDir);
|
FCu-H2O/annotatedBubbles/FCu-H2O-BubbleContours.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
FCu-H2O/annotatedBubbles/FCu-H2O_100W_00030.jpg
ADDED
|
Git LFS Details
|
FCu-H2O/annotatedBubbles/FCu-H2O_100W_00140.jpg
ADDED
|
Git LFS Details
|
FCu-H2O/annotatedBubbles/FCu-H2O_60W_01670.jpg
ADDED
|
Git LFS Details
|
FCu-H2O/annotatedBubbles/FCu-H2O_60W_02220.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O-BubbleContours.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
PCu-H2O/annotatedBubbles/PCu-H2O_130W_02400.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_130W_02700.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_130W_02750.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_00750.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_00900.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_01200.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_01500.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_01800.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_02100.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_02400.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_02700.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_02750.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_40W_03000.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_00000.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_00300.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_00600.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_00750.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_00900.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_01200.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_01500.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_01800.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_02100.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_02400.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_02700.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_02750.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_60W_03000.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_00000.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_00300.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_00600.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_00750.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_00900.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_01200.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_01500.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_01800.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_02100.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_02400.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_02700.jpg
ADDED
|
Git LFS Details
|
PCu-H2O/annotatedBubbles/PCu-H2O_90W_02750.jpg
ADDED
|
Git LFS Details
|
PSi-HFE/annotatedBubbles/PSi-HFE-BubbleContours.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
SSi-HFE/annotatedBubbles/SSi-HFE-BubbleContours.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|