x y相关对象上的区域属性-Matlab
我有一个txt文件,包含多行中的坐标xy。当我使用readtable时,我将其作为2列表。如何将其转换为逻辑,以便我在it regionprop上使用?您可以使用该函数轻松完成此操作:x y相关对象上的区域属性-Matlab,matlab,Matlab,我有一个txt文件,包含多行中的坐标xy。当我使用readtable时,我将其作为2列表。如何将其转换为逻辑,以便我在it regionprop上使用?您可以使用该函数轻松完成此操作: t = table([5; 2; 3; 4], [2; 3; 3; 1]); % example table with two columns y = full(sparse(t{:,1}, t{:,2}, true)); % or full(sparse(t{:,2}, t{:,1}, true)); 这给
t = table([5; 2; 3; 4], [2; 3; 3; 1]); % example table with two columns
y = full(sparse(t{:,1}, t{:,2}, true)); % or full(sparse(t{:,2}, t{:,1}, true));
这给
y =
5×3 logical array
0 0 0
0 0 1
0 0 1
1 0 0
0 1 0
如果表中可能有重复的条目,请使用
y = full(sparse(t{:,1}, t{:,2}, 1)); % or full(sparse(t{:,2}, t{:,1}, 1));
获取每个坐标对在表中出现的次数计数;然后可能会转换为逻辑。这也可以通过以下方式实现:
根据需要的属性,自己计算图像时刻可能更容易。
y = accumarray([t{:,1} t{:,2}], 1); % or accumarray([t{:,2} t{:,1}], 1)