How to get a centroid of polyarea?
Here is my code.
Thanks.
figure, imshow('000445.png')hold onxy = [];n = 0;but = 1;while but == 1 [xi,yi,but] = ginput(1); plot(xi,yi,'r.') n = n+1; xy(:,n) = [xi;yi];endt = 1:n;ts = 1: 0.1: n;xys = spline(t,xy,ts);plot(xys(1,:),xys(2,:),'r-');A = polyarea(xys(1,:),xys(2,:));plot(xys(1,:),xys(2,:),'r-');title (['Area = ' num2str(A)]);axis imagehold off
Best Answer