Find a submatrix in a matrix
Show older comments
How can I find a sub matrix in a larger one. We learned how to extract objects from an image using filter2 and bwlabel. But I still can't understand how to find a sub matrix in a larger one. And to find out how many of them are in that matrix
Answers (1)
Image Analyst
on 20 Nov 2015
0 votes
You can use normalized cross correlation, normxcorr2(). See attached demo.

2 Comments
Raed Alaraj
on 20 Nov 2015
Edited: Image Analyst
on 20 Nov 2015
Image Analyst
on 20 Nov 2015
Whoever used that method did so because they wanted to find edges, rather than find an exact submatrix like you asked for. They are basically finding the gradient magnitude manually rather than using the preferred built-in functions imgradient() or imgradientxy(). Then they label the edges, which, assuming the edges are completely closed around the circle, will identify each ring/perimeter as a separate connected blob. It doesn't have anything at all to do with circles, except that they were in the demo image. The same code would find perimeters of any objects of any shape whatsoever. That code doesn't have anything at all to do with what you asked for.
Categories
Find more on Object Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!