neighbours

Netlogo: asking a turtle to count its neighbors

孤人 提交于 2021-01-29 20:21:17
问题 I´m asking a turtle to count its neighboring turtles that are healthy with the following code let healthy-neighbors count turtles-on neighbors with [infected? = false] I get the following: You can´t use INFECTED? in a patch context, because INFECTED? is turtle-only My mistake must be basic, but can't find it, any help? 回答1: NetLogo is seeing that as turtles-on (neighbors with [infected? = false) , and since neighbors gives an agentset of patches, the with clauses is expecting patches, but

Fastest way to check each neighbor in 2D array

早过忘川 提交于 2019-12-13 03:55:48
问题 I am working on a random dungeon generator just for fun / as a side project to learn some new things. I have written a function that returns an integer hash value for any given cell, which gives you information about what type of gameobject it should be. i.e. if it is a wall, what direction to face, is it a corner, etc. Here is what the function currently looks like. private int CellHashValue(int xIndex, int yIndex, char centerTile) { int hashValue = 0; if (dungeon2DArray[xIndex - 1, yIndex +

in matlab, find 3D neighbourhood

丶灬走出姿态 提交于 2019-12-10 19:22:54
问题 I have a volume (3D matrix) that has undergone a segmentation process. Most of the volume consist of NaNs (or zeros), except regions that have passed some criteria (see picture). I need to know how large each remaining segment is in number of voxels and how is their distribution on the 2D planes (xy, xz, yz). Is there anything in matlab that can help me do this in an efficient way rather than direct search? The volume can be rather large. For ex. in the attached picture there is one segment

Determine adjacent regions in numpy array

泪湿孤枕 提交于 2019-12-07 05:15:00
问题 I am looking for the following. I have a numpy array which is labeled as regions. The numpy array represents a segmented image. A region is a number of adjacent cells with the same value. Each region has its own unique value. A simplified version with 3 regions would look like this: x = np.array([[1, 1, 1], [1, 1, 2], [2, 2, 2], [3, 3, 3]], np.int32) output: array([[1, 1, 1], [1, 1, 2], [2, 2, 2], [3, 3, 3]]) In the above example we have 3 separate regions, each labeled with an unique value

Matlab function to compute average neighbor degree

主宰稳场 提交于 2019-12-06 11:39:23
问题 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 cannot convert it to an adjacency matrix.. this will occupy too much of space actually. What i have is the following edge list(Actually this is just a test matrix.. the actual one is pretty large ) as in there's an edge between node 2 to node 1

numpy sliding 2d window calculations

女生的网名这么多〃 提交于 2019-12-06 04:45:23
问题 I'm trying to learn a way to use numpy to efficiently solve problems that involve a sliding window in a variety of circumstances. Here is an example illustrating the type of problem I'm interested in: I have a large 2d matrix, and I'd like to perform calculations on neighbors of every element in the matrix. For example, I may want to find the max value, excluding some special value of negibors at indexes at (x-1,y)(x+1,y+1) at each index, and put the result into another different 2d "solution

Determine adjacent regions in numpy array

核能气质少年 提交于 2019-12-05 10:47:28
I am looking for the following. I have a numpy array which is labeled as regions. The numpy array represents a segmented image. A region is a number of adjacent cells with the same value. Each region has its own unique value. A simplified version with 3 regions would look like this: x = np.array([[1, 1, 1], [1, 1, 2], [2, 2, 2], [3, 3, 3]], np.int32) output: array([[1, 1, 1], [1, 1, 2], [2, 2, 2], [3, 3, 3]]) In the above example we have 3 separate regions, each labeled with an unique value (1,2,3 in this case). What I want is the value of adjacent (neighbor) regions for each individual region

Matlab function to compute average neighbor degree

孤街醉人 提交于 2019-12-04 15:01:55
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 cannot convert it to an adjacency matrix.. this will occupy too much of space actually. What i have is the following edge list(Actually this is just a test matrix.. the actual one is pretty large ) as in there's an edge between node 2 to node 1 and so on.. and yes this is an un-directed graph 2 1 3 1 4 1 5 1 1 2 3 2 4 2 1 3 2 3 5 3 1 4 2 4 5 4 1 5

numpy sliding 2d window calculations

不羁的心 提交于 2019-12-04 09:58:36
I'm trying to learn a way to use numpy to efficiently solve problems that involve a sliding window in a variety of circumstances. Here is an example illustrating the type of problem I'm interested in: I have a large 2d matrix, and I'd like to perform calculations on neighbors of every element in the matrix. For example, I may want to find the max value, excluding some special value of negibors at indexes at (x-1,y)(x+1,y+1) at each index, and put the result into another different 2d "solution" matrix. Note that convolution2d, while useful won't work for me in this situation because I have

Spatial Data Structures for moving objects?

柔情痞子 提交于 2019-12-03 05:50:43
问题 I was wondering what is the best data structure to deal with a lot of moving objects(spheres, triangles, boxes, points, etc)? I'm trying to answer two questions, Nearest Neighbor and Collsion detection. I do realize that traditionally, data structures like R trees are used for nearest neighbor queries and Oct/Kd/BSP are used for collision detection problems dealing with static objects, or with very few moving objects. I'm just hoping that there is something else out there that is better. I