An efficient way to create a 2D array.
1 view (last 30 days)
Show older comments
Hey everyone, I am new to matlab. Here is my question:
Suppose, I = [a b c d e; f g h i j; k l m n o; p q r s t];
If (I(current pixel) == I(neighbour pixel)) then E(current pixel,neighbor pixel) = 1; else E(current pixel, neighbor pixel) = 0;
whereas a neighbor pixel is any pixel in 3x3 window centered at the current pixel. (I think this convention is know as the 8-neighbor)
One possible way is to use doubly nested for loop. Is there any more efficient way (using any of these (<http://www.mathworks.com/help/matlab/elementary-matrices-and-arrays.html>) data structure) and please write a hint how to use it since I cannot figure it out by myself.
2 Comments
David Sanchez
on 20 Jun 2013
who do you consider the neighbour pixel(s)? Only the pixel next to the current pixel (left, right, both) ?
Answers (0)
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!