Rework get_mask function
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 19 Aug 2024 12:23:02 +0000 (14:23 +0200)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 19 Aug 2024 12:51:34 +0000 (14:51 +0200)
Move get_mask to get_simple_mask, and make get_mask get the final mask.

get_mask.m
get_simple_mask.m [new file with mode: 0644]

index 28232d9b079e46b95ecfe097e16e36156e67a530..98a470e40684a0638eca4058075c5568d30bbf24 100644 (file)
@@ -1,14 +1,6 @@
-function mask = get_mask(changefig, meanfig, threshold, strength)
-       if nargin < 3
-               threshold = 200;
-       end
-
-       mask = (changefig > threshold);
-       if nargin >= 4
-               mask = clean_mask(mask, strength);
-       else
-               mask = clean_mask(mask);
-       end
-       mask = double(mask);
+function mask = get_mask(changefig, meanfig)
+       change_mask = get_simple_mask(changefig, 200);
+       mean_mask = get_simple_mask(meanfig, 60);
+       mask = change_mask .* mean_mask;
 end
 
diff --git a/get_simple_mask.m b/get_simple_mask.m
new file mode 100644 (file)
index 0000000..a0d974f
--- /dev/null
@@ -0,0 +1,10 @@
+function mask = get_simple_mask(fig, threshold, strength)
+       mask = (fig > threshold);
+       if nargin >= 3
+               mask = clean_mask(mask, strength);
+       else
+               mask = clean_mask(mask);
+       end
+       mask = double(mask);
+end
+