Thank you very much Prabhu

The following suggestion given by you worked well-

------------------------------------------------
from mayavi import mlab
import numpy as np

N = 10
x, y, z = np.random.random((3, N))
rgba = np.random.randint(0, 256, size=(N, 4), dtype=np.uint8)
rgba[:, -1] = 255
src = mlab.pipeline.scalar_scatter(x, y, z)
src.add_attribute(rgba, 'colors')
src.data.point_data.set_active_scalars('colors')
g = mlab.pipeline.glyph(src)
g.glyph.glyph.scale_factor = 0.1
mlab.show()
------------------------------------------------

Please see the screenshot shared via DropBox-
https://www.dropbox.com/s/f8xdlq726qy1uaj/mayavi.png?dl=0

Is it possible to set the same radius for all the points? I really want to see all points in same radius.

-
Thanks
Ravi


On 2018-07-22 23:06, Shankar Kulumani wrote:
The documentation shows a solution by using an additional scalar value
and a colormap:

The documentation is very thorough and shows a good example as well

http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html#points3d

import numpy
from mayavi.mlab import *

def test_points3d():
    t = numpy.linspace(0, 4 * numpy.pi, 20)
    cos = numpy.cos
    sin = numpy.sin

    x = sin(2 * t)
    y = cos(t)
    z = cos(2 * t)
    s = 2 + sin(t)

    return points3d(x, y, z, s, colormap="copper", scale_factor=.25)

On Sun, Jul 22, 2018 at 4:39 AM <mys...@ravijoshi.info> wrote:

Hi,

Thank you very much. I almost reached there. points3d is working
however, I am having a hard time in assigning colors to each point.
Please see the code snippet below-

-------------------------------------
import numpy as np
from mayavi import mlab

# generate random data (just for checking)
pts = 10 # number of points (just for checking)
x = np.arange(pts)
y = np.arange(pts)
z = np.arange(pts)
c = np.random.rand(pts, 3) #r, g, b values

mlab.figure()
mlab.points3d(x, y, z, color=c)
mlab.show()
-------------------------------------

The above code throws following error-
The 'color' trait of a GlyphFactory instance must be a tuple of the
form: (0.0 <= a floating point number <= 1.0, 0.0 <= a floating
point
number <= 1.0, 0.0 <= a floating point number <= 1.0) or None, but a

value of array([[...]]) <type 'numpy.ndarray'> was specified.

It seems that the color is a tuple i.e., (r, g, b)in mlab.points3d()

function and it is globally applied to all points. However, in my
case,
each point has a color value, which is different from others.

The simplest thing which came to my mind is to assign each point one
by
one as shown below-

-------------------------------------
mlab.figure()
for i in range(pts):
mlab.points3d(x[i], y[i], z[i], color=tuple(c[i].reshape(-1)))
mlab.show()
-------------------------------------

This works fine for a few points. However, I have approximately
40,000
points and the above approach isn't working!

-
Thanks
Ravi

On 2018-07-21 22:12, Shankar Kulumani wrote:
This function will do exactly what you want



http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html#points3d

Example

points3d(x, y, z...)
points3d(x, y, z, s, ...)
points3d(x, y, z, f, ...)

On Sat, Jul 21, 2018, 03:12 <mys...@ravijoshi.info> wrote:

Hello,

I am new to mayavi and I am trying to use mayavi in python to
visualize
a point cloud. I have a colored point cloud
(PointCloud<PointXYZRGB>)
stored in a numpy array of shape (40000, 4). The first three
columns
of
this array are the position in 3D space (x, y, z) and the last
column is
RGB color packed in one using the following formulation-

// pack r/g/b into rgb
uint8_t r = 255, g = 0, b = 0;    // Example: Red color
uint32_t rgb = ((uint32_t)r << 16 | (uint32_t)g << 8 |
(uint32_t)b);

Hence, the point cloud contains 40,000 points in which each point
has a
color assigned to it.

I want to know if it is possible to visualize it using mayavi
python?
Any sample code will be appreciated more.

-
Thanks
Ravi




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to