Hi community,
I have a matrix containing numbers 1 and 2, where numbers 2s are 'the background'. In this manner, in my matrix there are small groups of numbers 1s embedded in a lot of numbers 2. I need to do a 'cleaning step' of this matrix, looking for linear groups of only one column and several rows of numbers 1s, being able to convert them in numbers 2s. I would like to be able to choose which is the starting amount of numbers 1s in which the modification must be performed.
For example, considering this matrix:
[2 2 2 2 2 2 2 2 2 2; 2 1 1 2 1 2 1 2 1 2; 2 1 1 2 1 2 1 2 2 2; 2 2 2 2 1 2 1 2 1 2; 2 2 2 2 2 2 1 2 1 2; 2 2 2 2 2 2 2 2 2 2]
If I select as a threshold value 3, the intended output is to look for linear groups of 3 or more 1s, and convert them into number 2:
[2 2 2 2 2 2 2 2 2 2; 2 1 1 2 2 2 2 2 1 2; 2 1 1 2 2 2 2 2 2 2; 2 2 2 2 2 2 2 2 1 2; 2 2 2 2 2 2 2 2 1 2; 2 2 2 2 2 2 2 2 2 2]
Thank you very much for your collaboration!
Best Answer