Comments (19)
In fact, there are four labels in total(maybe more). The current obj file only contains three of them (label 2 may represent skirt).
For a batch of data, I can map 0,1,2,3 to four colors, and then color it according to the label information.
from vedo.
Hi @LogWell
this looks related to a transparency problem in vtk.. though I must say I don't understand exactly why that happens.. This works for me:
from vtkplotter import *
settings.useDepthPeeling = True
m = load('00000.obj').texture('registered_tex_1_m.png')
m.show(axes=4)
from vedo.
various possibilities..:
if the points are projectable onto a plane (which seems to be the case) you can discard the existing triangles and recreate a new mesh with delaunay2D
or
try to recreate it with recoSurface()
besides
you can use clean(tol=0.01)
to preprocess and reduce the points and/or use smoothMLS2D()
to make the surface smoother.
finally - once you have the mesh - you can color the outside and inside differently with color()
and backColor()
from vedo.
Hi
I'm adding now this functionality and let you know asap
M
from vedo.
@marcomusy Thanks. Please let me know if I can help out in any way. I just got started with VTK but I do have some experience in Python and data visualization.
from vedo.
please have a look at examples/mesh_coloring.py
from vedo.
This is pretty incredible!!
I just ran your example file with some of my manikins and it works great..
..and just for fun, I tried a more complex model (with nearly 100,000 surfaces and missing geometry) and that loads too!
I think this library could be used to visualize a whole lot of building science data in 3D.
cc: @mostaphaRoudsari
from vedo.
Thanks,
keep in mind you can control the scalarbar to have it horizontal e.i.:
vp.addScalarBar(man3, horizontal=True)
from vedo.
@marcomusy Thanks for the tip. Which API do you to refer to for Python-specifc functionality within VTK? I have come across an API and documentation for the C++ version, however, it appears that not all the classes and methods have been ported over to the Python version.
from vedo.
I typically use the latest version of vtk (8.1 as it comes in anaconda) so I guess all the c++ methods are ported to python, older vtk versions might not have the latest features. I don't think that there is anything like a specific python api for reference...
If you load any mesh at command line you should be able to get a message of which version you are running, e.g.:
./plotter.py anymesh.obj
from vedo.
I don't think that there is anything like a specific python api for reference...
That's the case with most libraries ported to Python, except PyQT. Anyway, thank you for getting this project started. I will circle back in case I come up with more "interesting" queries.
from vedo.
vtk documentation is not very good..
if you have any other questions/query don't hesitate to ask,
cheers
M
from vedo.
code:
from vtkplotter import *
import numpy as np
sc = load('scan_c.obj')
data_label = np.load('scan_labels.npy').reshape(-1)
sc.pointColors(data_label, alpha=1, mode='scalars')
show(sc, Text('seg', c='k'), bg='w', interactive=True)
question:
1,2: Shown in OpenFlipper and vtkplotter, difference caused by ?interpolation???
3,4: How to color a single element(vertex or face) without interpolation?
PS: In scan.obj
, only v
and vt
are stored, but f
indexes to vn
. It can be opened in meshlab and OpenFlipper, exception handling should be done, can you handle such abnormal data?
PS: How to set transparent background?
from vedo.
Hi @LogWell please pull the latest commit and try the following:
from vtkplotter import load, show, colors
import numpy as np
sc = load('scan_c.obj')
data_label = np.load('scan_labels.npy').reshape(-1)
# Optionally build a lookup table of colors:
# scalar, color
lut = colors.makeLUT([( 0, 'pink'),
( 1, 'green'),
( 3, 'yellow'),
],
N=4, # specify total nr. of colors
)
sc.pointColors(data_label, cmap=lut).addScalarBar()
#sc.mapPointsToCells() # this would translate point data to cell data
# avoid interpolating cell colors:
sc.mapper.InterpolateScalarsBeforeMappingOff()
show(sc, bg='w')
PS: In scan.obj, only v and vt are stored, but f indexes to vn. It can be opened in meshlab and OpenFlipper, exception handling should be done, can you handle such abnormal data?
Unfortunately vtk seems unable to handle this faulty data..
PS: How to set transparent background?
from vtkplotter import settings
settings.screenshotTransparentBackground = True
from vedo.
NOTE: The red dot in the leftmost yellow circle in the previous image may be caused by abnormal data scan.obj
, correct as shown in fig_1, same as in vtkplotter.
Q:
-
How to color single point rather transm to face, like in fig_2? ref here?
-
Thanks for your example of using
colors.makeLUT
. I'm a little confused about setting the correct color in fig_3.
from vedo.
- consider the following where points can be overlapped to mesh if you wish:
from vtkplotter import load, show, makeLUT, Points
import numpy as np
sc = load('/home/musy/downloads/scan/scan_c.obj')
data_label = np.load('/home/musy/downloads/scan/scan_labels.npy').reshape(-1)
# build a lookup table of colors:
# scalar, color
lut = makeLUT([( 0, 'red'),
( 1, 'green'),
( 3, 'gold'),
],
N=4, # specify total nr. of colors
)
sc.pointColors(data_label, cmap=lut).addScalarBar()
# avoid interpolating cell colors:
sc.mapper.InterpolateScalarsBeforeMappingOff()
pts = Points(sc.coordinates()).pointColors(data_label, cmap=lut)
show(sc, pts, N=2, bg='w')
- make sure you have pulled the latest version from git.
note that in your scalar file you only have values 0,1,3 and 2 is absent.
Plus you have a typo "bule" instead of "blue".
Let me know if you can reproduce the above figure.
from vedo.
I realized that my first try at fixing this was not great.. :) I modified the makeLUT() function, so the above now becomes:
from vtkplotter import load, show, makeLUT, Points
import numpy as np
sc = load('/home/musy/downloads/scan/scan_c.obj')
data_label = np.load('/home/musy/downloads/scan/scan_labels.npy').reshape(-1)
# build a lookup table of colors:
# scalar, color alpha
lut = makeLUT([( 0, 'red' ),
( 1, 'green', 0.5),
( 3, 'gold' ),
],
interpolate=False,
)
sc.pointColors(data_label, cmap=lut).addScalarBar()
# avoid interpolating cell colors:
sc.mapper.InterpolateScalarsBeforeMappingOff()
pts = Points(sc.coordinates()).pointColors(data_label, cmap=lut)
show(sc, pts, N=2, bg='w')
this also includes setting opacities if a 3rd element is given in the list.
Hope this works for you.
from vedo.
Hi, marcomusy~
The result seems strange after I subdivided the mesh. It looks a little bit like a flip from the inside view, but the normal of faces are correct in meshlab.
How to solve this problem?
from vedo.
@marcomusy How to render a mesh like this(you can distinguish between inside and outside):
from vedo.
Related Issues (20)
- What pointdata are filled with in cut mesh? HOT 8
- Rounding when saving/reading an obj HOT 5
- AttributeError: 'NoneType' object has no attribute 'pos' HOT 8
- Smooth boundary line of a mesh HOT 2
- How to open two seperate windows in vedo ? HOT 4
- color of tube cap HOT 4
- How to show import window in multiple renderer ? HOT 3
- Boolean operations issue HOT 2
- how to remove vtk log HOT 2
- How to quantify the volume of a Volume HOT 6
- Memory Leak in Image(img), Axes function ? HOT 6
- Adjacent connections and distance between adjacent point clouds HOT 4
- AttributeError: partially initialized module 'vedo' has no attribute 'Cone' (most likely due to a circular import) HOT 1
- Axisymmetric mesh with extrude HOT 4
- Is vedo thread-safe? HOT 1
- Want to use vedo to display and reconstruct 3D CT images HOT 4
- Data type discrepancies between numpy and VTK HOT 11
- About the button in vedo. HOT 2
- How to set a camera with given intrinsic and extrinsic parameters HOT 1
- How to add the slider? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vedo.