Matlab area calculation -
if have arbitrary shape (attached simple mock up), how estimate area of enclosed surface in matlab. random points along curve, used ginput command rough estimate of curve, unequal spacing between points. want estimate of area, believe trapz command overestimate area due overlap (please correct me if wrong here). there more accurate way obtain area?
well, didn't give enough info solve problem entirely, here's 1 approach can take find boundary automatically in order calculate area:
% image , convert logical mask img = ~im2bw(imread('polyarea.jpg')); % fill hole img = imfill(img,'holes'); % boundary b = bwboundaries(img); % approximate area of boundary area = polyarea(b{1}(:,1), b{1}(:,2)); % print area disp(['area: ' num2str(area)]); imshow(img); hold on; plot(b{1}(:,2),b{1}(:,1),'go'); the idea have input, form logical mask, boundary of mask, , can approximate area enclosed boundary using polyarea.
the output is:
area: 228003 additionally, use regionprops(img,'area') outputs:
ans = area: 229154 


Comments
Post a Comment