I possess a binary sparse symmetric matrix with square blocks centered on its main diagonal (white=0, black=1). These can be of any size and can overlap. I aim to detect centers of these squares using some image processing approach (red dots) in MATLAB. As the size of the matrix may get very large, techniques such as region growing while traversing the main diagonal is very inefficient. Can anyone have a suggestion on this?
"Image processing method" here really boils down to ... "for" loops.
You'd walk the main diagonal (or the first non-main diagonal next to it), and as soon as you hit a value, you count the values right of that aren't 0. Soon as you know how many these are, you're done. Half that number, add it to the number of the row, and tadah, center of square.
To deal with overlap is trivial: once you've reached the end of a row go one element further and then you go up until you hit either the diagonal or another non-zero value.
Note that you say "sparse" matrix: depending on the matrix storage format, the "how many entries are set in this row" might already be how the whole thing is stored, making this even easier.