Select largest object in an image
Use bwconncomp instead since it returns the coordinate indexes for region in a separate cell, where the size of each is easily discerned: >> BW = [1 0 0; 0 0 0; 0 1 1]; % two regions >> CC = bwconncomp(BW) CC = Connectivity: 8 ImageSize: [3 3] NumObjects: 2 PixelIdxList: {[1] [2×1 double]} … Read more