selecting submatrix of like elements
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I need to be able to search a matrix for a submatrix of like elements and then manipulate that group of like elements. For example:
A= [0 0 0 0 0; 0 1 1 0 0; 0 1 1 0 0; 0 0 0 0]
I would like to be able to get at
B= [1 1, 1 1]
and then I would like to randomly move B within A.
The purpose of this is to make a quick demo where I get some tiles to conditionally stick together during a random walk and form larger structures which in turn rotate and move randomly.
0 Commenti
Risposte (1)
Walter Roberson
il 25 Apr 2014
Are the values integers? If so then using the image processing toolbox would possibly be easiest. You can use bwlabel() to find the "islands" in flexible ways, using 4-connection (must be left or right, or up or down) or 8-connection (diagonals allowed) or other custom rules. regionprops() can then give you information about the blobs including lists of coordinates.
Vedere anche
Categorie
Scopri di più su Denoising and Compression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!