Questions tagged [neighbours]

166 questions
0
votes
1 answer

I know how to check the 4-neighbourhood, but how to combine it here?

Say we want to check the 4-neighbourhood in matlab, I think we can do the following (correct me if I'm wrong): I = imread('cameraman.tif'); structured_element = [0,1,0;1,1,1;0,1,0]; o = imdilate(I,structured_element); Now, I have the following…
Simplicity
  • 47,404
  • 98
  • 256
  • 385
0
votes
1 answer

check if array coordinates neighbour cyclical array point

I have a 3d array with dimensions M x N x L, which defines the values on a cyclical volume (i.e. the M-1'th point is next to the 0th point, if we're zero indexing). If I'm given the coordinates of a point (X, Y, Z), how can I neatly find all the…
tiswas
  • 2,041
  • 7
  • 31
  • 43
0
votes
2 answers

Matlab - get neighbouring cells with condition / Move function

I have a big square matrix of structs which represents creatures. Each creature can move left,up,right or down. I'm checking the neighbouring matrix positions for empty cells and do the following calculation for the new coordinates: function res =…
Guy Wald
  • 599
  • 1
  • 10
  • 25
0
votes
1 answer

Find K-farthest neighbors in a weighted graph in matlab

I want to find the K-farthest neighbors in a given undirected weighted graph (the graph is given as a sparse weight matrix, but I can use an representation advised). Just to make sure the problem is well-defined: I want to find k nodes which have…
olamundo
  • 23,991
  • 34
  • 108
  • 149
-1
votes
1 answer

Create dummy variable for all neighborhood region depending on another dummy variable (sf object)

I have a spatial dataframe (sf) of all European NUTS2 regions. Within this sf object certain regions have a dummy = 1, and others a dummy = 0. How can I create a new dummy (lets say "dummy_neighbor") where all the neighboring (st_touches?) regions…
Tom
  • 25
  • 5
-1
votes
1 answer

How to compare the local variables of a turtle with its neighbors

I am trying to compare the local variables of a turtle, with its neighbors and trying to find out the total number of neighbors which match this criterion total-nearby = total number of neighbors. I am checking according to the color of the turtles,…
-1
votes
1 answer

Counting the number of neighbors in common between two vertices in R

I have tried to compute the number of neighbors in common between two vertices. the test file contain 1 2 1 4 1 5 2 3 2 4 2 5 3 4 y<-read.table("test.txt") require(igraph) g<-graph.data.frame(y, directed=F, vertices=NULL) for(i in 1:5) { for(j…
Camilla
  • 117
  • 1
  • 10
-1
votes
1 answer

How to move to another agent with the highest value?

my agents set trade_Price than when they trade and they save their profit to their payoff variable. in ai process I have to code that my agents have to look around and choose the neighbor agent with the highest payoff. and than the agent has to give…
runle
  • 149
  • 8
-1
votes
1 answer

two functions reading a txt file, using elif

so i have been trying to get these two function to work, when i do them sepretly they work, but when i combine the two functions using the elif function, it only runs the 1st function and prints out position list, and an error says"the…
-1
votes
1 answer

DFS isn't working on 2d array

So I have a a 2darray of colors. The colors are represented by numbers. I have made a dfs that currently only checks for the number 1, which is red. I don;t think I hav the code right. I have a get neighbors that does get the neighbors around the…
user2835532
  • 113
  • 1
  • 1
  • 10
-1
votes
1 answer

Finding the neighbourhood of certain pixels

I have an image which matrix has some pixels with value NaN. For such certain pixel, I want to compare its 8-neighbourhood, and assign it a value based on that neighborhood. I think for the neighbourhood we use nlfilter? How can I do that in…
Simplicity
  • 47,404
  • 98
  • 256
  • 385
-2
votes
1 answer

Finding the number of the neighbours of a given node of a multiway tree (rose tree) in Haskell

Consider the following definition of a Rose Tree: The tree can contains unique nodes. data NTree a = Nil | Node { root :: a, subtree :: [NTree a]} deriving Show -- or just data NTree a = Nil | Node a [NTree a] t1 :: NTree Int t1 = Node 1 [Node 2 […
-3
votes
1 answer

C# Check for neighbours

I have a function to check neighbors of an array and if that element is equal with 1. X is for each neighbor found and v[l] is the position for each 0. I have a problem with this code each time gives me "Index was outside the bounds of the array"…
user3215160
  • 21
  • 1
  • 2
-4
votes
1 answer

4-neighbours of a pixel

I know that there is a function called nlfilter in matlab. What I'm trying to find is the 4-neighbours of a pixel. Does that means a 2x2 window? Can we do that using nlfilter? Thanks.
Simplicity
  • 47,404
  • 98
  • 256
  • 385
-7
votes
2 answers

Trying to find neighbour cells in a 2D array and getting IndexOutOfBounds

I created a 2D array (a Cell[][] grid) and each cell contains an ArrayList with the name neighborCells; and now I am trying to find its neighbour cells but I am getting the IndexOutOfBoundsException. Can you help? ArrayList neighborCells = new…
1 2 3
11
12