谁能建议使用 MATLBAB 检测下图中每个目标中心的替代方法:
我目前的方法使用 regionprops 和质心检测。
clc, clear all, close all
format long
beep off
rng('default')
I=imread('WP_20160811_13_38_26_Pro.jpg');
BW=im2bw(I);
BW=imcomplement(BW);
s = regionprops(BW, 'area','Centroid');
centroids = cat(1, s.Centroid);
imshow(BW)
hold on
plot(centroids(:,1), centroids(:,2), 'b*')
hold off
是否有更精确的检测中心的方法,因为这种方法似乎对噪声、透视失真等敏感。有没有办法找到两个四分之一圆的交点。
最佳答案
我的修改对您的图像有 100% 的效率:
I = imadjust(imcomplement(rgb2gray(imread('WP_20160811_13_38_26_Pro.jpg'))));
filtered_BW = bwareaopen(im2bw(I), 500, 4);
% 500 is the area of ignored objects
final_BW = imdilate(filtered_BW, strel('disk', 5));
s = regionprops(final_BW, 'area','Centroid');
centroids = cat(1, s([s.Area] < 10000).Centroid);
% the condition leaves out the big areas on both sides
figure; imshow(final_BW)
hold on
plot(centroids(:,1), centroids(:,2), 'b*')
hold off
我添加的功能:
rgb2gray
具有一维值!imadjust
自动优化亮度和对比度,bwareaopen
去除小岛,imdilate
和strel
扩大区域并连接断开的区域。
关于matlab - 在 MATLAB 中检测目标中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38954662/