Fix path in create_mask and create_meter
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 17 Dec 2024 09:03:34 +0000 (10:03 +0100)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 17 Dec 2024 09:03:34 +0000 (10:03 +0100)
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
create_meter.m

index 3b95859e6cc9d55bdcaa0d1356941f40c1cf1d19..06ea59e9a48309f9c474a31e0593afe6e9cb15ab 100644 (file)
@@ -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);
index 0fc1d303beb15636c475dab78410308ba6c61521..f47ede203122e6b8768dd624efd1297340fc757b 100644 (file)
@@ -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