From b1a173b4c9dc16d710c5abc6a6c958b18617041a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Tue, 17 Dec 2024 10:03:34 +0100 Subject: [PATCH] Fix path in create_mask and create_meter Matlab is using path for where to look for functions. I used path as a file path, overwriting the Matlab method. This is now solved. Create_mask also can accept a single file now (even though it makes little sense). --- create_mask.m | 18 +++++++++++------- create_meter.m | 8 ++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/create_mask.m b/create_mask.m index 3b95859..06ea59e 100644 --- a/create_mask.m +++ b/create_mask.m @@ -4,20 +4,24 @@ oldpath = addpath('./functions'); FileType = '*.png'; last_path = get_last_path(); -[filenames, path] = uigetfile([last_path '/' FileType], ... +[filenames, new_path] = uigetfile([last_path '/' FileType], ... 'Select all files for mask creation', 'MultiSelect', 'on'); -update_last_path(path); -files = struct('name', cell(1, numel(filenames)), 'folder', cell(1,... -numel(filenames))); +if (isequal(filenames, 0)) + path(oldpath); + return ; +end +filenames = cellstr(filenames); +update_last_path(new_path); +files = struct('name', cell(1, numel(filenames)), 'folder', cell(1, numel(filenames))); [files.name] = deal(filenames{:}); -[files.folder] = deal(path); +[files.folder] = deal(new_path); [minfig, maxfig, meanfig] = get_aggregate_images(files); changefig = maxfig - minfig; mask = get_mask(changefig, meanfig); figure(); imshow(meanfig .* uint8(mask)); -[mask_file_name, mask_path] = uiputfile([path '/*.pbm'], 'Save you mask as...'); -if (mask_file_name ~= 0) +[mask_file_name, mask_path] = uiputfile([new_path '/*.pbm'], 'Save you mask as...'); +if (~isequal(mask_file_name, 0)) imwrite(mask, [mask_path '/' mask_file_name], 'PBM', 'Encoding', 'raw'); end path(oldpath); diff --git a/create_meter.m b/create_meter.m index 0fc1d30..f47ede2 100644 --- a/create_meter.m +++ b/create_meter.m @@ -4,14 +4,14 @@ oldpath = addpath('./functions'); FileType = '*.png'; last_path = get_last_path(); -[filenames, last_path] = uigetfile([last_path '/' FileType], ... +[filenames, new_path] = uigetfile([last_path '/' FileType], ... 'Select all files for meter creation', 'MultiSelect', 'on'); if (isequal(filenames, 0)) path(oldpath); return ; end filenames = cellstr(filenames); -update_last_path(last_path); +update_last_path(new_path); mask = load_mask(); if (isequal(mask, 0)) path(oldpath); @@ -20,7 +20,7 @@ end files = struct('name', cell(1, numel(filenames)), 'folder', cell(1,... numel(filenames))); [files.name] = deal(filenames{:}); -[files.folder] = deal(last_path); +[files.folder] = deal(new_path); [minfig, maxfig, meanfig] = get_aggregate_images(files); [meter, inverse] = get_meter(maxfig, mask, 2); figure(); @@ -34,7 +34,7 @@ for i = 1:numel(marks_pixels) line([line_x line_x], [0 pic_size(1)], 'Color', 'red') end end -[meter_file_name, meter_path] = uiputfile([path '/*.mtr'], 'Save your meter as...'); +[meter_file_name, meter_path] = uiputfile([new_path '/*.mtr'], 'Save your meter as...'); if (~isequal(meter_file_name, 0)) save_meter([meter_path '/' meter_file_name], meter) end -- 2.30.2