【发布时间】:2014-01-20 17:25:06
【问题描述】:
我正在做一些图像处理,我必须操纵 houghlines() 的结果并手动连接一些线。
给出以下 houghlines() -result (我缩短了 point1 和 point2 的条目以保持清晰):
lines(1) = struct('theta', 69, 'rho', 14);
lines(2) = struct('theta', 70, 'rho', 32);
lines(3) = struct('theta', 69, 'rho', 14);
lines(4) = struct('theta', 69, 'rho', 20);
lines(5) = struct('theta', 70, 'rho', 32);
现在,如果 theta 和 rho 的值相等,我想提取特定的行,以便以后可以手动连接 Houghlines。 结果应该是行结构的相应行。像这样:
A = [lines(1) lines(3)];
B = [lines(2) lines(5)];
C = [lines(4)];
我无法像上面的代码那样明确地解决问题,因为 houglines() 已应用于视频。这意味着 theta、rho 的值甚至 lines 的长度对于每一帧都是不同的。 所以这必须动态评估。
我发现使用 FileExchange 中的 nestedStruct() 我可以先按 theta 然后按 rho 对我的结构进行排序。在这一点上,我无法拆卸结构,因为我不知道我必须为生成的结构采用多少元素。
我还尝试了 unique() 索引,但没有成功。
我希望有人能给我一个提示。
提前致谢。
【问题讨论】:
标签: arrays matlab data-structures struct