Quantcast
Channel: Listing adjacent cells - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by Hooked for Listing adjacent cells

Let me give an alternate answer with numpy, which is a library you might want to consider if you're doing anything a bit more heavy duty with your data. The advantage with this method is the...

View Article



Answer by pillmuncher for Listing adjacent cells

code with no coordinates? Do you mean like this:XMAX = 800YMAX = 570NEIGHBOURS = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]matrix = range(XMAX * YMAX)def all_neighbours(m):...

View Article

Answer by Andrew Walker for Listing adjacent cells

Assuming that what you're trying to do is construct an eight-connected grid on the matrix, and that the position of item in the the matrix defines an x- and y- co-ordinate, you can use something like...

View Article

Listing adjacent cells

I have a 570 x 800 matrix with id values. What I would like to do if find the adjacent neighbors for each item. The max number of neighbors would be 8 unless the cell is along a boundary. In that case,...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images