Questions tagged [neighbours]
166 questions
2
votes
3 answers
How to find neighbors in binary image with given horizontal and vertical distance (Python)
I have an Image (or several hundreds of them) that need to be analyzed. The goal is to find all black spots close to each other.
For example all black spots with a Horizontal distance of 160 pixel and vertical 40 pixel.
For now I just look at each…

Kuchen
- 108
- 7
2
votes
2 answers
Calculate neighbor values in array
Given a list of tuples, [(x1, y1), (x2, y2) ... (xm, ym)] such as [(1, 2), (3, 7), (5, 9)] I would like to write a function that fills in the missing integer values x with the average of the neighbor values f(x - 1), f(x + 1).
In this case, we would…

compguy24
- 937
- 16
- 33
2
votes
2 answers
Vector Convolution - Calculating the Index of a Neighbour Element
I am trying to implement a convolution method taking two vectors: an image; and a kernel. My problem is that i don't know how to calculate the index of the image neighbour element when I "slide" the kernel over the image vector. For example, with…

5had3sofQu4rtz
- 504
- 5
- 15
2
votes
3 answers
Avoid clash of positions in a matrix algorithm
Assume you have a n x m matrix. In this matrix, you will be randomly positioning FOUR different objects say a, b, c, d. There will be many of each.
Now what is the best algorithm so that when they are randomly placed, their positions don't clash?
My…

VideoGamingIOs
- 119
- 1
- 9
2
votes
3 answers
How to find neighbor element of array 1 from reverse of the same array
function compareNumbers(x, y) {
return x - y;
}
var a = [3,6,2,7,8,10,43] //I have one array
var b = a.slice().sort(compareNumbers).reverse(); //I reverse this array
//Now I have 2 arrays
a = [3,6,2,7,8,10,43]
b = [43, 10, 8, 7, 6, 3, 2]
My…

Mansi
- 35
- 1
- 7
2
votes
0 answers
C++: Find neighbouring grid points from calibration picture from unsorted list
I do have 4 lists of the x and y coordinates of calibration points. Those are in no particular order and not alligned on any axis (they come from a real calibration picture with slight rotation and distortion) but the lists have the same indexing…

Dominic
- 452
- 4
- 20
2
votes
1 answer
Moore neighbourhood in python
I have a grid as a tuple of tuples with integers (1/0), a row number and column number for a cell as integers. And I have to find how many neighbouring cells have neighbours as an integer.
It's a task from the www.checkio.org, an interesting site of…

laVitaEBella
- 25
- 1
- 3
2
votes
1 answer
Matlab function to compute average neighbor degree
I tried searching a function for matlab that gives the average neighbor degree of a graph.
There is a function for the same in python in network-X package. So i was wondering if there's a similar function in matlab.
***********Edit****************
I…

SeasonalShot
- 2,357
- 3
- 31
- 49
2
votes
2 answers
How do I calculate neighborhood contiguity in R?
My end goal is to calculate join counts, using the function joincounts.multi() from the R package spdep.
I have a very large raster file (nrows = 19663, ncols = 34073), with cell size of 30 m. It is a binary raster with two values, 0 and 1 (and many…

user3251223
- 265
- 1
- 7
- 15
2
votes
2 answers
Optimizing (Vectorizing?) For loop with nested loop in R
I am using rdist iteratively in order to compute nearest neighbours for huge datasets. Currently I have a rather small matrix of 634,000 vectors with 6 columns.
As mentioned I'm using rdist to compute the distance of each vector to every single…

Artur Motruk
- 23
- 3
2
votes
4 answers
neighbor analysis in MATLAB
I have an m-by-n matrix named A, with values 1s and 0s. I want to convert all 0s values to 1s if at least 5 out of 8 neighbor pixels are 1s. What I tried is to use the nlfilter function, but I'm not getting how the arg fun should be used, and I…

umbe1987
- 2,894
- 6
- 35
- 63
2
votes
5 answers
Select surrounding rows php/mysql
I want to select a group of rows around a row matched on conditions, ie select a row and then return 5 records before and after it.
More info as requested (sorry bout that!)
Ok, so the table records lap times from a race. Laps are related to Users…

designvoid
- 431
- 1
- 6
- 19
2
votes
1 answer
Create a neighbourhood graph from a list of voxels faster than in O(n^2)?
I'm currently creating a "neighbourhood graph" by doing roughly this:
for every voxel
look at every other unseen voxel
check if neighbours
which runs roughly in n squared (minus n). It is acceptable for a certain number of voxels, but…

Manux
- 3,643
- 4
- 30
- 42
1
vote
2 answers
Array diagonal neighbourhood analysis and sort
I've been battling with this for some time and seem to be getting nowhere. The set up is so; I have a 2D array. For this array I need to iterate through each value and return the diagonal neighbours (5 values). These neighbours will be put into a…

Oliver Burdekin
- 1,098
- 2
- 17
- 36
1
vote
2 answers
Find all unique neighbor pairs between segments of ndimage labeling in an efficient manner
Below I give an example in 2D, but my real question would be regarding 3D (with or without periodic boundaries). Find all unique neighbors for each segment id using 8 neighbors (2d) or 26 neighbors (3d).
Given the following array:
INPUT
matrix=[
…

Bart Bruininks
- 11
- 3