Looking to identify a football from an image

9 ビュー (過去 30 日間)
Michael Sposato
Michael Sposato 2022 年 9 月 29 日
コメント済み: Michael Sposato 2022 年 10 月 5 日
I currently have a still image of a football about to be kicked. I would like to identify the ball and it's center.

回答 (1 件)

Kevin Holly
Kevin Holly 2022 年 9 月 30 日
RGB = imread('YourImage.png');
% Convert RGB image to lab space
I = rgb2lab(RGB);
% Apply thresholds
BW = (I(:,:,1) >= 14.5 ) & (I(:,:,1) <= 89.77) & ...
(I(:,:,2) >= 0.12) & (I(:,:,2) <= 12.5) & ...
(I(:,:,3) >= 3.8) & (I(:,:,3) <= 33.0);
% Open mask
se = strel('disk', 13,0);
BW = imopen(BW, se);
% Filter out smaller objects
BW=bwareafilt(BW,[50000 Inf]);
% Find Centroid and Area of object
rp = regionprops(BW,"Centroid","Area")
rp = struct with fields:
Area: 58864 Centroid: [644.7752 215.7900]
% Display masked image for verfication purposes
maskedRGBImage = RGB;
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;
imshow(maskedRGBImage)
% Add marker on centroid
hold on
scatter(rp.Centroid(1),rp.Centroid(2),'b','filled')
  1 件のコメント
Michael Sposato
Michael Sposato 2022 年 10 月 5 日
I also need this to work for other images as well. What is there to change to do this? I attached another sample image as well.
Also how is the centroid calculated? Is it by the extremes or by matlab calculating the area of the ellipse?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by