# How to calculate a Delaunay mesh nerve?

How to calculate a Delaunay mesh nerve? A Delaunay mesh nerve is a collection of triangles that surround a single triangle called the nerve nucleus. The triangles in a Delaunay mesh nerve either have a common edge or a common vertex with the nerve nucleus. Here, nerve nucleus means that triangle which has maximum area in a Delaunay mesh.

Here is the code I developed to find the Delaunay mesh. But, I can't calculate the mesh nerve. Please kindly let me know. Thanks.

c = ImageCorners[img, MaxFeatures -> 200];
dm = DelaunayMesh[c];

• I am unfamiliar with the concept of the "nerve" of a mesh, and a quick google search did not return anything pertinent. Could you perhaps point to a web site with a definition and a few examples. Feb 1, 2016 at 4:22
• A Delaunay mesh nerve is a collection of triangles that surround a single triangle called the nerve nucleus. The triangles in a Delaunay mesh nerve either have a common edge or a common vertex with the nerve nucleus.Here, Nerve nucleus means that triangle which has maximum area in a Delaunay mesh. Feb 1, 2016 at 21:23
• OK thank you for the clarification regarding the definition of the nucleus. Please take a look at my answer below. Feb 2, 2016 at 5:52
• Related: (105201) Feb 3, 2016 at 14:08
• @Mr.Wizard I would say it's not an exact duplicate. The question you mention asks for the polygon with the most adjacent polygons in a mesh; that polygon does not necessarily have to be the one with the largest area. Feb 3, 2016 at 14:30

The approach I would take is the following:

1. Clear definitions, load a sample image, find corners in the image using the method you indicated in the OP:

Clear[img, points, dm, cells, nerve, nervenucleus]
img = ExampleData[{"TestImage", "Aerial2"}];
points = ImageCorners[img, MaxFeatures -> 200];

2. Generate a Delaunay mesh from those points:

dm = DelaunayMesh[
points, PlotTheme -> "Lines",
MeshCellStyle -> Directive[EdgeForm[GrayLevel[0.3]], Opacity[0]]
];

Show[img, dm]


3. Extract the coordinates for the two-dimensional cells (triangles) that make up the mesh:

cells = MeshPrimitives[dm, 2];

4. Find the "nucleus", which you defined as the triangle with the largest area in the mesh:

nucleus = First@MaximalBy[cells, Area];
Show[img, dm, Graphics[{Opacity[0.4], Red, nucleus}]]


5. Find the "nerve", that you defined as the set of cells that share a vertex or an edge with the nucleus (note that the nucleus itself is not included in this list thanks to the second part of the condition):

nerve = Cases[
cells,
Polygon[{p1_, p2_, p3_}] /;
(
ContainsAny[{p1, p2, p3}, nucleus[[1]] ] && {p1, p2, p3} != nucleus[[1]]
)
];

6. Show all results:

Show[img, dm, Graphics[{Opacity[0.4], Red, nucleus, Darker@Green, nerve}]]