Commit 9f50d739 authored by Michael Krause's avatar Michael Krause 🎉
Browse files

Fix incompatibility to Matlab

parent ee41abec
......@@ -38,13 +38,19 @@ if all(all(all(mask == 0)))
end
% get cuboid around mask
mins(1) = find(sum(squeeze(sum(mask, 3)), 2) ~= 0)(1);
mins(2) = find(sum(squeeze(sum(mask, 3)), 1) ~= 0)(1);
mins(3) = find(sum(squeeze(sum(mask, 2)), 1) ~= 0)(1);
tmpvec = find(sum(squeeze(sum(mask, 3)), 2) ~= 0);
mins(1) = tmpvec(1);
tmpvec = find(sum(squeeze(sum(mask, 3)), 1) ~= 0);
mins(2) = tmpvec(1);
tmpvec = find(sum(squeeze(sum(mask, 2)), 1) ~= 0);
mins(3) = tmpvec(1);
maxs(1) = find(sum(squeeze(sum(mask, 2)), 2) ~= 0)(end);
maxs(2) = find(sum(squeeze(sum(mask, 1)), 2) ~= 0)(end);
maxs(3) = find(sum(squeeze(sum(mask, 1)), 1) ~= 0)(end);
tmpvec = find(sum(squeeze(sum(mask, 3)), 2) ~= 0);
maxs(1) = tmpvec(end);
tmpvec = find(sum(squeeze(sum(mask, 3)), 1) ~= 0);
maxs(2) = tmpvec(end);
tmpvec = find(sum(squeeze(sum(mask, 2)), 1) ~= 0);
maxs(3) = tmpvec(end);
% apply mask
matrix = matrix .* mask;
......
......@@ -10,7 +10,8 @@ zs = zeros(d, d, d);
mask(1:l, 1:l, 1:l) = 1;
s = zipmask_pack(m, mask);
[um, umask] = zipmask_unpack(s);
assert(umask, mask);
assert(isequal(umask, mask));
assert(isequal(um, m .* mask));
end
function test_plane()
......@@ -18,7 +19,8 @@ zs = zeros(d, d, d);
mask(:, :, 1) = 1;
s = zipmask_pack(m, mask);
[um, umask] = zipmask_unpack(s);
assert(umask, mask);
assert(isequal(umask, mask));
assert(isequal(um, m .* mask));
end
function test_sphere()
......@@ -27,7 +29,7 @@ zs = zeros(d, d, d);
for x = 1:d
for y = 1:d
for z = 1:d
if (x - c)**2 + (y - c)**2 + (z - c)**2 <= 4
if (x - c)^2 + (y - c)^2 + (z - c)^2 <= 4
mask(x, y, z) = 1;
end
end
......@@ -35,8 +37,8 @@ zs = zeros(d, d, d);
end
s = zipmask_pack(m, mask);
[um, umask] = zipmask_unpack(s);
assert(umask, mask);
assert(um, m .* mask);
assert(isequal(umask, mask));
assert(isequal(um, m .* mask));
clear x y z;
end
......@@ -46,16 +48,16 @@ zs = zeros(d, d, d);
mask(p(1), p(2), p(3)) = 1;
s = zipmask_pack(m, mask);
[um, umask] = zipmask_unpack(s);
assert(umask, mask);
assert(um, m .* mask);
assert(isequal(umask, mask));
assert(isequal(um, m .* mask));
end
function test_empty()
mask = zs;
s = zipmask_pack(m, mask);
[um, umask] = zipmask_unpack(s);
assert(umask, mask);
assert(um, m .* mask);
assert(isequal(umask, mask));
assert(isequal(um, m .* mask));
end
test_cube()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment