hi guys, this is my first project in matlab can anyone help me with this? I am trying to find robocup`s ball. because it is orange , so I separated this color and after that test if it is round or not…
rgb = imread('E:/robot4.jpg'); 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);[B,L] = bwboundaries(ball1,'noholes');stats = regionprops(L,'Area','perimeter');for k = 1:length(B)area = stats(k).Area;s=stats(k).Perimeter;endmetric=s^2/(4*pi*area);if (metric>0.8)stat = regionprops(ball1,'centroid');imshow(rgb); hold on; for x = 1: numel(stat) plot(stat(x).Centroid(1),stat(x).Centroid(2), 'wp','MarkerSize',20,'MarkerFaceColor','b'); endend
this shows every orange things and also ball !!! I guess it has problem in calculating perimeter, but I dont know how can I solve it
Best Answer