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