BW21=imread('m1.jpg');
%Step 1: Label each object using the following code.
ppp = imbinarize(BW21); % be sure your image is binary
L= bwlabel(ppp); % label each object
%Step 2: see the label of each object
s = regionprops(L,'Centroid');
imshow(ppp)
hold on
Code Analyzer has found a call of regionprops with a first argument that is a call to bwlabel. In many cases, the argument of bwlabel is a logical matrix, or you can convert it to one. Beginning in MATLAB Version 7.8 (release R2009a), you can pass this logical matrix directly to regionprops without the call to bwlabel. This is faster and uses less space than the previous method.
Suggested Action
If bw is a logical matrix, make the indicated change. If bw is not a logical matrix, convert it to a logical matrix, and then pass the converted matrix as the first argument to regionprops.
For example, if bw is a logical matrix, replace:
regionprops(bwlabel(bw), …)
with:
regionprops(bw, ….)
Best Answer