How can I eliminate ghost detection?
5 次查看(过去 30 天)
显示 更早的评论
I am tracking an object but I got a problem because my program detects a ghost object. How can I eliminate this? A screenshot is shown.

3 个评论
Walter Roberson
2018-8-29
编辑:Walter Roberson
2018-8-29
The above code loops over the number of centroids but does nothing with them, and does not display anything.
It would help if we had the original image to test with. And the value of threshold .
回答(2 个)
Walter Roberson
2018-8-28
You have attempted to index your image array as (X, Y) . That is incorrect: images arrays need to be indexed as (Y, X) in MATLAB. The first index in MATLAB, the row index, is considered to be the vertical distance (so the Y) and the second index in MATLAB, the column index, is considered to be the horizontal distance (so the X)
0 个评论
Image Analyst
2018-8-29
You can get rid of half that program just by using bwareafilt():
biggest_object = bwareafilt(im, 1); % Extract largest blob only.
props = regionprops(biggest_object, 'Centroid');
if length(props) == 0 % If nothing is there, bail out.
return;
end
% Get centroid and plot it.
xCentroid = props.Centroid(1);
yCentroid = props.Centroid(2);
hold on;
plot(xCentroid, yCentroid, 'r+', 'MarkerSize', 30);
No need for the for loop, calls to size(), and other things you have there.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!