MATLAB: How to fill the area bounded by vertices (represented using 1s), in an array. Below the array A has values of 1 where there are vertices. I am looking for a method to do this for any rectangular polygon defined by an even set of vertex coordinates

array manipulationfill between verticiesvertex bounds

%row_vert = [1 1 4 4 8 8 4 4]; %col_vert = [1 9 9 6 6 4 4 1]; %represents T-shaped plate with 1's at vertices
A = [1 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0; 1 0 0 1 0 1 0 0 1; 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0; 0 0 0 1 0 1 0 0 0];

Best Answer

T=zeros(max(row_vert),max(col_vert));
T(sub2ind(size(T),r,c))=1
Related Question