Helper Module for Deep Learning.
Module that provides spherical sampling & associated utilities.
-
pynet.models.spherical.sampling.downsample(vertices, target_vertices)[source]¶ Downsample by finding nearest neighbors.
- Parameters
vertices: array (n_samples, n_dim)
points of data set.
target_vertices: array (n_query, n_dim)
points to find nearest neighbors for.
- Returns
nearest_idx: array (n_query, )
index of nearest neighbor in target_vertices for every point in vertices.
-
pynet.models.spherical.sampling.get_angle_with_xaxis(center, normal, point)[source]¶ Project a point to the sphere tangent plane and compute the angle with the x-axis.
- Parameters
center: array (3, )
a point in the plane.
normal: array (3, )
the normal to the plane.
points: array (3, )
the points to be projected.
-
pynet.models.spherical.sampling.get_rectangular_projection(node, size=5, zoom=5)[source]¶ Project rectangular grid in 2D sapce into 3D spherical space.
- Parameters
node: array (3, )
a point in the sphere.
size: int, default 5
the rectangular grid size.
zoom: int, default 5
scale factor applied on the unit sphere to control the neighborhood density.
- Returns
grid_in_sphere: array (size**2, 3)
zoomed rectangular grid on the sphere.
grid_in_tplane: array (size**2, 3)
zoomed rectangular grid in the tangent space.
-
pynet.models.spherical.sampling.icosahedron(order=3)[source]¶ Define an icosahedron mesh of any order.
- Parameters
order: int, default 3
the icosahedron order.
- Returns
vertices: array (N, 3)
the icosahedron vertices.
triangles: array (N, 3)
the icosahedron triangles.
-
pynet.models.spherical.sampling.interpolate(vertices, target_vertices, target_triangles)[source]¶ Interpolate missing data.
- Parameters
vertices: array (n_samples, n_dim)
points of data set.
target_vertices: array (n_query, n_dim)
points to find interpolated texture for.
target_triangles: array (n_query, 3)
the mesh geometry definition.
- Returns
interp_textures: array (n_query, n_feats)
the interplatedd textures.
-
pynet.models.spherical.sampling.middle_point(point_1, point_2, vertices, middle_point_cache)[source]¶ Find a middle point and project to the unit sphere.
-
pynet.models.spherical.sampling.neighbors(vertices, triangles, depth=1, direct_neighbor=False)[source]¶ Build mesh vertices neighbors.
- Parameters
vertices: array (N, 3)
the icosahedron vertices.
triangles: array (N, 3)
the icosahedron triangles.
depth: int, default 1
depth to stop the neighbors search, only paths of length <= depth are returned.
direct_neighbor: bool, default False
each spherical surface is composed of two types of vertices: 1) 12 vertices with each having only 5 direct neighbors; and 2) the remaining vertices with each having 6 direct neighbors. For those vertices with 6 neighbors, DiNe assigns the index 1 to the center vertex and the indices 2–7 to its neighbors sequentially according to the angle between the vector of center vertex to neighboring vertex and the x-axis in the tangent plane. For the 12 vertices with only 5 neighbors, DiNe assigns the indices both 1 and 2 to the center vertex, and indices 3–7 to the neighbors in the same way as those vertices with 6 neighbors.
- Returns
neighs: dict
a dictionary with vertices row index as keys and a dictionary of neighbors vertices row indexes organized by rungs as values.
-
pynet.models.spherical.sampling.neighbors_rec(vertices, triangles, size=5, zoom=5)[source]¶ Build rectangular grid neighbors and weights.
- Parameters
vertices: array (N, 3)
the icosahedron vertices.
triangles: array (N, 3)
the icosahedron triangles.
size: int, default 5
the rectangular grid size.
zoom: int, default 5
scale factor applied on the unit sphere to control the neighborhood density.
- Returns
neighs: array (N, size**2, 3)
grid samples neighbors for each vertex.
weights: array (N, size**2, 3)
grid samples weights with neighbors for each vertex.
grid_in_sphere: array (N, size**2, 3)
zoomed rectangular grid on the sphere vertices.
-
pynet.models.spherical.sampling.normalize(vertex)[source]¶ Return vertex coordinates fixed to the unit sphere.
-
pynet.models.spherical.sampling.number_of_ico_vertices(order=3)[source]¶ Get the number of vertices of an icosahedron of specific order.
- Parameters
order: int, default 3
the icosahedron order.
- Returns
vertices: array (N, 3)
the icosahedron vertices.
triangles: array (N, 3)
the icosahedron triangles.
-
pynet.models.spherical.sampling.triangles_to_edges(triangles, return_index=False)[source]¶ Given a list of triangles, return a list of edges.
- Parameters
triangles: array int (N, 3)
Vertex indices representing triangles.
- Returns
edges: array int (N * 3, 2)
Vertex indices representing edges.
triangles_index: array (N * 3, )
Triangle indexes.
-
pynet.models.spherical.sampling.vertex_adjacency_graph(vertices, triangles)[source]¶ Build a networkx graph representation of the vertices and their connections in the mesh.
- Parameters
vertices: array (N, 3)
the icosahedron vertices.
triangles: array (N, 3)
the icosahedron triangles.
- Returns
graph: networkx.Graph
Graph representing vertices and edges between them where vertices are nodes and edges are edges
Examples
This is useful for getting nearby vertices for a given vertex, potentially for some simple smoothing techniques. >>> graph = mesh.vertex_adjacency_graph >>> graph.neighbors(0) > [1, 3, 4]
Follow us
Inspired by AZMIND template.