Detecting Particular line and circle.
이전 댓글 표시
Hi guys this is my code. my task is to detect white line in green field and yellow goal post and orange ball. I am unable to detect the ball and yellow line and it is detecting all white line. i just want green field white line should get detected and yellow goal post and orange ball. PLEASE HELP ME THANK YOU.
imread ('C:\Users\new\Desktop\Ass1\robocup_image1.jpeg');
img = imread ('C:\Users\new\Desktop\Ass1\robocup_image1.jpeg');
imshow (img);
RGB = imread ('C:\Users\new\Desktop\Ass1\robocup_image1.jpeg');
imshow (RGB);
I = rgb2gray(RGB);
imshow(I)
BW = edge(I,'Canny');
imshow(BW)
[H,theta,rho] = hough(BW);
figure, imshow(imadjust(mat2gray(H)),[],'XData',theta,'YData',rho,...
'InitialMagnification','fit');
xlabel('\theta (degrees)'), ylabel('\rho');
axis on, axis normal, hold on;
colormap(hot)
P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));
x = theta(P(:,2));
y = rho(P(:,1));
plot(x,y,'s','color','black');
lines = houghlines(BW,theta,rho,P,'FillGap',5,'MinLength',7);
figure, imshow(BW), hold on
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% Plot beginnings and ends of lines
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
% Determine the endpoints of the longest line segment
len = norm(lines(k).point1 - lines(k).point2);
if ( len > max_len)
max_len = len;
xy_long = xy;
end
end
답변 (1개)
Image Analyst
2015년 5월 8일
0 개 추천
See my color segmentation routines in my File Exchange http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
In addition see attachment where I track a green Sharpie marker.
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!