I am doing a project where I track a table tennis ball from two different angles and determine its position. However, I've run into a problem. In the background there is an orange light to the left and a pack of doritos to the right and my program is detecting these instead of my ball. How can this be solved?
function angle = Image(image)rgb = image;imshow(rgb);hsv=rgb2hsv(rgb);h=hsv(: , : ,1);s=hsv(: , : ,2);v=hsv( : , : ,3);bw= (h>0.05 & h<0.12) & (s>0.6) & (v> 0.51);imagesc(bw)colormap(gray)se = strel('disk',2);bw = imclose(bw,se);bw = imfill(bw,'holes');imshow(bw)ball1 = bwareaopen(bw, 50);imagesc(ball1);lab = bwlabel(ball1);s = regionprops(lab, 'Area', 'Perimeter');sArea = [s.Area];sPerim= [s.Perimeter];metric= sPerim.^2/(4*pi.* sArea);idx = find(metric > 1);gr_fin = ismember(lab, idx);imshow(gr_fin)stat = regionprops(gr_fin,'centroid');imshow(rgb); hold on;pos = [stat.Centroid(1), stat.Centroid(2)];plot(pos(1),pos(2),'r+', 'MarkerSize', 50);
I am attaching an image captured as well.
%
Best Answer