Neighbor and center points of matrix
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have matirx of 256 \times 256. I want to find and save indices of nine neighbors of each center point in 1D matrix or in 256\times 256 matrix.
2 Kommentare
Jan
am 30 Dez. 2020
What does "each center point" mean? Can you give a small example of the wanted output?
Antworten (1)
Steve Eddins
am 30 Dez. 2020
You'll need to pay careful attention to what happens with matrix elements that are on the edges of the matrix, as these elements don't have nine neighbors. I often zero-pad to simplify the code.
Also, in that blog post, you'll see this line of code:
neighbors = bsxfun(@plus, idx, neighbor_offsets)
In today's MATLAB, you can write that more simply as:
neighbors = idx + neighbor_offsets
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!