Info

This question is closed. Reopen it to edit or answer.

why different answers with roipoly and polyarea

1 view (last 30 days)
Cecil
Cecil on 18 Oct 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
clear all close all
nrows=300; ncols=400; N=4; % number of vertices
ang=0:360/N:360; ang=ang+45; radius=min(nrows,ncols)/2; h=ncols/2+radius*cosd(ang); v=nrows/2+radius*sind(ang);
im=zeros(nrows,ncols); im=roipoly(im,h,v); area=sum(sum(im)) area2=polyarea(h,v)

Answers (1)

Sachin Ganjare
Sachin Ganjare on 18 Oct 2012
'roipoly' is used to get manually the region of interest
'polyarea' is used to calculate the ROI area
Example:
% imshow first, then:
[x, y, BW, xi, yi] = roipoly;
area = polyarea(xi,yi);
Hope it helps!!!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!