Looking to identify a football from an image
33 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I currently have a still image of a football about to be kicked. I would like to identify the ball and it's center. 

0 Kommentare
Antworten (2)
Kevin Holly
am 30 Sep. 2022
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")
% 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')
Image Analyst
am 3 Okt. 2025 um 14:27
You can use transfer learning to identify footballs in a variety of images with a variety of colors, orientations, sizes, etc. See this answer:
2 Kommentare
Vicente
am 21 Okt. 2025 um 15:38
Hi @Image Analyst, im working on a colour analysis project, and i have been reading a lot of your comments about colour science in this place.
Can I take advantage of this conversation to ask you some questions about this?
I found in some of your comments your PPT post where you explain a process of correction in RGB and calibration to LAB. I am trying to do the latter. I tried to build a calibration to transform photos from SRGB to Lab. To do this, I built a least squares regression to obtain a transformation equation, using the RGB values obtained from a color checker in my images and its reference Lab values.
My question is: for colour analysis applications where I need to extract reliable Lab or RGB values, what’s the recommended photo format and processing pipeline? Should I use RAW/Bayer images and linearize them, or is a high-quality PNG good enough?
Image Analyst
am 22 Okt. 2025 um 1:52
What I do is to set the gamma of my camera to 1 so that there is no nonlinear transform applied to the captured image. If you don't have a machine vision camera where you have that kind of control, then I need to know what you want to do. If you're just doing segmentation (like finding areas/regions) then it may not be necessary to do all the operations that you need to do if you were wanting color measurement traceable to a spectrophotometer. If you do want to do accurate color measurement that will give you LAB values very close to what you'd get from a spectrophotometer, then you really need a good machine vision or scientific/industrial camera where you can do white balancing and specify the gamma, and turn the automatic gain control and automatic exposure control off -- it must be fully manual because you don't want the camera doing any funny unknown things in an attempt to be helpful. If you are stuck with a camera where the PNG or TIFF or JPG image has a gamma, then you can still use the ColorChecker chart to develop a transform. The transform will attempt to "undo" the gamma and linearize it. If you use a higher order transform than the 3x3 matrix that MATLAB uses
then you could do a better job than doing it the way MATLAB shows you. However if you want to do it all with built-in MATLAB functions (using their 3x3 matrices) then you can but it won't be quite as accurate as doing it yourself manually with a higher order transform (like I do). So if you do it yourself, again, I'd use a machine vision camera that you can set gamma=1 and turn off all automatic adjustments, and but if you can't then the higher order transform will somewhat "undo" the gamma. Or you could linearize it first with that link and then do the custom higher order transform. Though it won't be as close to a spectrophotometer it may be good enough for whatever you want to do, which I don't know what that is (saying you want to measure color is not a "use case" and is very vague).
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
