Import mesh in python - python

I'm trying to import a mesh as vertices and faces (connectivity list) in python. Possibly supporting mixed tri/quad meshes.
I don't have any particular requirement on the format of the mesh, as from the CAD software (Rhino) I can export several different formats, including *.stl, *.obj, *.fbx, etc.
I tried different packages as numpy-stl, trimesh, pymesh, but couldn't find any one working. Some of these are completely bugged, other does not allow you (or I couldn't find how) generate the connectivity list.
Is there any package for python that allows to do so?

Related

OPENCV how do i map two slightly similar images in different orientation onto eachother

I have 2 images from different sources, and want to map them onto eachother because they both contain different information.
i am quite new to opencv and similar toolings, is there a way to automatically find the right orientation and location of the frame of the other image?
This is a classical image registration problem.
There are registration modules in scikit-image and opencv, though I am not sure how useful is the one in scikit-image: their examples only include shifts, but you also need rotations. The module in opencv includes different kinds of deformations and also provides tutorials on registration and alignment.
Another option would be to use the registration tool provided by the ANTs software

Plot vertex as image in Igraph

I'm wondering if it is possible to plot a vertex as image (loaded from a file or directly) in Igraph. Any ideas?
This is definitley possible in the R version of iGraph using the raster function, however a brief search did not reveal any implementation of this function in Python (it's not in the igraph documentation anyway).
If this is essential to your work, then I would consider switching to R, or possibly another tool such as Gephi. For Python, however, you might consider using something like pyvis. This package is small but powerful in terms of visualization. I've been playing around with it over the past few days and its very easy to display a graph with pictures as nodes, and it comes with the added benefit of providing interactive functioning. Take a look at the tutorial here, which will highlight what this package can provide.

Handle package sknw in python

Is there any official documentation for building graphes associated to skeletons of images in python in the SKNW package? I found this package that I've installed, however, since I'm new in python, it's not easy for me to handle the latter: https://github.com/yxdragon/sknw .
Thanks for using sknw:
just load your 2d/3d image, you can use skimage.morphology.skeletonize_3d(img) to get a 3d skeleton from volume data.
graph = sknw.build_sknw(skeļ¼Œ multi=False) to got the skeleton structure, which is a networkx object.
do your analysis
graph.node[id]['pts'] : Numpy(x, n), coordinates of nodes points
graph.node[id]['o']: Numpy(n), centried of the node
graph.edge(id1, id2)['pts']: Numpy(x, n), sequence of the edge point
graph.edge(id1, id2)['weight']: float, length of this edge
and you can do some graph analysis use networkx.
I think you would be intrested in my another project ImagePy, which you can do many image processing operation in a UI framework, just like imagej

Artificially incorporate non-rigid motions in Images for generating data using Python/Matlab

The main challenges in Medical Imaging is Data acquisition. There are different types of motions (Rigid & Non Rigid) possible during acquitions(Body movement,breathing etc).
Suppose I want to generate different types of motion artificially in an Image(eg. 3D NIFTI MRI image).
Motions can be global rigid motions or elastic deformation or bspline based local deformations. Input will be an 3D image and output will be a newly generated data incorporated the desired motion.
I was wondering if there is any package or software available to do this, but didn't find any. Using this type of feature we can validate our registration methods or simulate different deformation models.
I want some help in generating such artificial data using python or matlab for NIFTI/DICOM 3D images.
Within Python, there are a couple options. The first is using the pydicom module for I/O along with numpy to represent/process the layers. In order to use this, you may additionally have to use matplotlib, scipy/scikit-image, or Pillow to visualize the input and generated output.
However there is also VTK, which comes with both a Python interface and a DICOM reader/writer. Using vtkpython will allow you to create a fairly simple application for viewing and interacting with the data. For generating the motion layers, I think numpy may still be the best option with this route.
This page has a good introduction to using both of these methods: https://pyscience.wordpress.com/2014/09/08/dicom-in-python-importing-medical-image-data-into-numpy-with-pydicom-and-vtk/

Tool to create a python GUI for graph construction

I need to create a GUI for graph construction ("graph" as an abstract representation of a set of objects, not a visual representation of data). The interface will provide a choice of ~5 vertex types and of ~5 edge types. Each vertex will have two data fields: a text label and a file name, which need to be easily editable.
I'm familiar with igraph and have a lot of code written in it. I will use igraph to manipulate the graphs created with this GUI.
Since this will be my first GUI, I'm completely ignorant of what tools are available. Can you please suggest a free library, knowing that eventually the program will need to work on Windows?
EDIT
it seems from the answers I get that I wasn't clear enough. I'm not looking for a way to visualize a graph, but rather for a way to visually create one. By visually, I mean not needing to manually create text files or writing code.
Take a look at xdot.py.
From the homepage
xdot.py is an interactive viewer for graphs written in Graphviz's
dot language.
It uses internally the graphviz's xdot output format as an
intermediate format, and PyGTK and Cairo for rendering.
xdot.py can be used either as a standalone application from
command line, or as a library embedded in your python application.
I like networkx,
from networkx import draw, Graph
from pylab import show
g = Graph()
g.add_edges_from([(1,2),(1,3),(2,4),(2,5)])
draw(g)
show()
which gives,
The only quirk is the requirement for matplotlib to get builtin plotting to work.
If you use python, I think PyQt is a good selection.
What you have to install is listed below:
install Python from here
install PyQt4 from here
But it takes many lines to write GUI application,
it is sometimes better to generate an image to display with image viewer.

Categories

Resources