0
任务是将我使用regionprops
的质心连接成水平行,然后预测丢失的对象。水平连接质心并检测丢失的对象
这里是形象地说,我有:
所有的重心一定y坐标范围内,应连接。之后,我想预测丢失的物体。例如,上图中的绿线上应该存在更多的对象/质心。
我迄今为止代码:
BW = rgb2gray(imread('noise_removal_single_25_cropped.png'));
props = regionprops(im2bw(BW), 'Centroid');
centroids = cat(1, props.Centroid);
[B,L] = bwboundaries(BW,'noholes');
imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end
plot(centroids(:,1),centroids(:,2), 'b*')
plot(centroids(:,1),centroids(:,2), 'k-')
代码垂直连接所有质心,我不知道如何检测丢失物件/心(可能会根据线路长度)?
你在哪里垂直连接质心?我只看到你在代码中绘制边界和质心。一种方法是找到每个最近邻居点。缺少点会导致邻居有比平常更大的距离。当然,你有知道你的观点水平分组的优势https://en.wikipedia.org/wiki/Nearest_neighbor_search – Piglet