aboutsummaryrefslogtreecommitdiff
path: root/webp/lossy_nearlossless_gen_graph.m
diff options
context:
space:
mode:
Diffstat (limited to 'webp/lossy_nearlossless_gen_graph.m')
-rwxr-xr-xwebp/lossy_nearlossless_gen_graph.m44
1 files changed, 44 insertions, 0 deletions
diff --git a/webp/lossy_nearlossless_gen_graph.m b/webp/lossy_nearlossless_gen_graph.m
new file mode 100755
index 0000000..cdc33a6
--- /dev/null
+++ b/webp/lossy_nearlossless_gen_graph.m
@@ -0,0 +1,44 @@
+#!/usr/bin/octave
+% SPDX-FileCopyrightText: 2023 Brian Woods
+% SPDX-License-Identifier: GPL-2.0-or-later
+
+graph_file = 'lossy_nearlossless_graph.png';
+img_dir = 'lossy_nearlossless_images/';
+varname = "nl";
+var_values = {'000', '010', '020', '030', ...
+ '040', '050', '060', '070', ...
+ '080', '090', '100'};
+
+files = {strrep(strcat(img_dir, 'PNG_01-VARN_VAR.webp'), 'VARN', varname), ...
+ strrep(strcat(img_dir, 'PNG_02-VARN_VAR.webp'), 'VARN', varname), ...
+ strrep(strcat(img_dir, 'PNG_03-VARN_VAR.webp'), 'VARN', varname), ...
+ strrep(strcat(img_dir, 'PNG_04-VARN_VAR.webp'), 'VARN', varname)};
+files_len = length(files);
+var_values_len = length(var_values);
+results = zeros(files_len, var_values_len);
+
+for i = 1:files_len
+ for j = 1:var_values_len;
+ filepath = strrep(files{i}, 'VAR', var_values{j});
+ [file, ~, ~] = stat(filepath);
+ results(i,j) = file.size;
+ end
+end
+
+% normalize
+for i = 1:files_len
+ results(i,:) = results(i,:)/max(results(i,:));
+end
+
+var_values_idx = str2double(var_values);
+f = figure('visible','off');
+plot(var_values_idx, results(1,:),"b-");
+hold on;
+plot(var_values_idx, results(2,:), "g-");
+plot(var_values_idx, results(3,:), "r-");
+plot(var_values_idx, results(4,:), "c-");
+xlabel ("near lossless preprocessing (0 is more visual compression)");
+ylabel ("normalized file size");
+h = legend ("PNG 01", "PNG 02", "PNG 03", "PNG 04");
+legend(h, "location", "northeastoutside");
+print(graph_file);