I have a mask with a certain numbers of rows and columns.
I would like to read just the (i,j) components that contains for example 1.
Then once the (i,j) component with 1 is found perform four different action if any of the (i+1,j),(i-i,j),(i,j+1),(i,j-1) equal to 1 is found.
Hope this is clear.
Any advice are welcome.
Thanks.
Let your mask be something like this:
Then the following fragment should point you in the right direction:
I’ll leave it to you to deal with the edge cases where
+/- i/jstep outside the array bounds.forallis not necessarily the fastest construction to use, and we could debate the elegance and readability of using it rather than a sequence of loops, but let’s not.