Exemple #1
0
from vedo import Picture, dataurl, show
import numpy as np

pic = Picture(dataurl + "images/dog.jpg").smooth(5)
msh = pic.tomesh()  # make a quad-mesh out of it

# build a scalar array with intensities
rgb = msh.pointdata["RGBA"]
intensity = np.sum(rgb, axis=1)
intensityz = np.zeros_like(rgb)
intensityz[:, 2] = intensity / 10

# set the new vertex points
pts = msh.points() + intensityz
msh.points(pts)

# more cosmetics
msh.triangulate().smooth()
msh.lighting("default").lineWidth(0.1)
msh.cmap("bone", "RGBA").addScalarBar()

msht = pic.clone().threshold(100).lineWidth(0)

show([[pic, "A normal jpg image.."], [msh, "..becomes a polygonal Mesh"],
      [msht, "Thresholding also generates a Mesh"]],
     N=3,
     axes=1,
     zoom=5,
     elevation=-20,
     bg='black').close()
Exemple #2
0
"""Normal jpg/png pictures can be loaded,
cropped, rotated and positioned in 3D."""
from vedo import Plotter, Picture, dataurl

plt = Plotter(axes=7)

pic = Picture(dataurl + "images/dog.jpg")

for i in range(5):
    p = pic.clone()
    p.crop(bottom=0.20)  # crop 20% from bottom
    p.scale(1 - i / 10.0).rotateX(20 * i).z(30 * i)
    p.alpha(0.8)
    plt += p

plt += __doc__
plt.show()
plt.close()