Clear Filters
Clear Filters

how Calculate the number of object(submatrix) in matlab?

1 view (last 30 days)
number of object =5
a=[0 0 0 0 0 0 0 0 0 0 0;0 0 1 1 1 1 0 1 0 1 1;0 0 1 0 1 0 1 1 1 0 0;0 1 1 1 1 0 1 0 1 0 0;1 0 1 0 1 0 1 1 1 0 0;1 0 1 1 1 1 0 0 0 0 0;0 0 0 0 0 0 1 1 1 0 0;0 1 1 1 1 0 1 0 1 0 0;0 0 1 0 1 0 1 1 1 0 0;0 0 1 1 1 0 0 0 0 0 0;0 1 0 0 0 0 0 0 0 0 0];
b=[1 1 1;1 0 1;1 1 1];

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 21 Nov 2015
sum(conv2(a,b) == 8)

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!