Check out example codes for "matlab components area". It will help you in understanding the concepts better.

Code Example 1

A = randi([0 1], [10 10]);
B = mat2gray(A);
% To consider the horizontal or vertical connectivity set connectivity parameter = 4.
cc = bwconncomp(B, 4);
% Calculate area of individual connected component.
Area = regionprops(cc,'Area');

Learn ReactJs, React Native from akashmittal.com