Octave contourc 格式 -> 点坐标
Octave contourc format -> point coordinates
octave以contourc格式保存一个轮廓的数据,这对我来说有点特殊。
是否有一些函数或脚本可以将这些数据转换成一系列
我可以绘制的点坐标?仅限一级!
谢谢
处理一个级别的 contourc 格式的示例(在该级别可能有多个轮廓)。
A = zeros(5); A(2:4,2:4) = 1; A(3,3) = 0; % example image
ContourCFormat = contourc(A, 1); % one level only (but here happens to have two contours)
C = cell();
while ~isempty(ContourCFormat)
N = ContourCFormat(2,1);
C{end+1} = ContourCFormat(:, 2 : 1+N);
ContourCFormat(:, 1 : 1+N) = []; % Remove processed points
end
C =
{
[1,1] =
1.5000 2.0000 3.0000 4.0000 4.5000 4.5000 4.5000 4.0000 3.0000 2.0000 1.5000 1.5000 1.5000
2.0000 1.5000 1.5000 1.5000 2.0000 3.0000 4.0000 4.5000 4.5000 4.5000 4.0000 3.0000 2.0000
[1,2] =
2.5000 3.0000 3.5000 3.0000 2.5000
3.0000 2.5000 3.0000 3.5000 3.0000
}
解释: 来自octave manual:
The return value is a 2xn matrix containing the contour lines in the following format:
[lev1, x1, x2, …, levn, x1, x2, ...
len1, y1, y2, …, lenn, y1, y2, …]
in which contour line n has a level (height) of levn
and length of lenn
.
因此,对于第一个轮廓,我们收集了从 2 到 N+1 的列,其中 N 由轮廓输出的元素 (2,1) 给出。然后我们删除N+1个元素,以同样的方式处理下一个轮廓,直到没有剩下的点。
octave以contourc格式保存一个轮廓的数据,这对我来说有点特殊。
是否有一些函数或脚本可以将这些数据转换成一系列 我可以绘制的点坐标?仅限一级!
谢谢
处理一个级别的 contourc 格式的示例(在该级别可能有多个轮廓)。
A = zeros(5); A(2:4,2:4) = 1; A(3,3) = 0; % example image
ContourCFormat = contourc(A, 1); % one level only (but here happens to have two contours)
C = cell();
while ~isempty(ContourCFormat)
N = ContourCFormat(2,1);
C{end+1} = ContourCFormat(:, 2 : 1+N);
ContourCFormat(:, 1 : 1+N) = []; % Remove processed points
end
C =
{
[1,1] =
1.5000 2.0000 3.0000 4.0000 4.5000 4.5000 4.5000 4.0000 3.0000 2.0000 1.5000 1.5000 1.5000
2.0000 1.5000 1.5000 1.5000 2.0000 3.0000 4.0000 4.5000 4.5000 4.5000 4.0000 3.0000 2.0000
[1,2] =
2.5000 3.0000 3.5000 3.0000 2.5000
3.0000 2.5000 3.0000 3.5000 3.0000
}
解释: 来自octave manual:
The return value is a 2xn matrix containing the contour lines in the following format:
[lev1, x1, x2, …, levn, x1, x2, ... len1, y1, y2, …, lenn, y1, y2, …]
in which contour line n has a level (height) of
levn
and length oflenn
.
因此,对于第一个轮廓,我们收集了从 2 到 N+1 的列,其中 N 由轮廓输出的元素 (2,1) 给出。然后我们删除N+1个元素,以同样的方式处理下一个轮廓,直到没有剩下的点。