question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scale/normalize point clouds of different dimensions

See original GitHub issue

Hi @marcomusy,

I have two point clouds (see attached file), they are of different dimensions and in different positions (actually in principle room4 is subpart of room6 with a different design). Now I wanted to scale/normalize them so that they are both in the same range e.g. (-1,1) in all three axis and without losing the aspect ratio.

I’ve tried to use the normalize() function but it didn’t really do what I want. Thus, I wanted to ask if there is another method which I can use, I did not find something on the documentation and scale() doesn’t seem to do what I want.

import numpy as np
import vedo as vd

room4 = np.genfromtxt('room4.csv', delimiter=',', dtype='float')
room6 = np.genfromtxt('room6.csv', delimiter=',', dtype='float')

pcd4 = vd.pointcloud.Points(room4).normalize()
pcd6 = vd.pointcloud.Points(room6).normalize()



axes4 = vd.addons.buildAxes(pcd4, c='k')
axes6 = vd.addons.buildAxes(pcd6, c='dg')
vd.show(pcd4, pcd6, axes4, axes6, axes=4)

rooms.zip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ttsesmcommented, Dec 27, 2020

I see, thanks.

I think, I will close this now.

1reaction
marcomusycommented, Dec 23, 2020

Hi - thanks for rising the issue. I think it’s actually something useful so i’ve added it as a vedo.base method (for the next release):


    def alignToBoundingBox(self, msh, rigid=False):
        """
        Align the current object's bounding box to the bounding box
        of the input object.

        :param bool rigid: do not allow scaling if set to True

        :Example:

            .. code-block:: python

                from vedo import *
                eli = Ellipsoid().alpha(0.4)
                cube= Cube().pos(3,2,1).rotateX(10).rotateZ(10).alpha(0.4)
                eli.alignToBoundingBox(cube, rigid=False)
                axes1 = Axes(eli, c='db')
                axes2 = Axes(cube, c='dg')
                show(eli, cube, axes1, axes2)
        """
        lmt = vtk.vtkLandmarkTransform()
        ss = vtk.vtkPoints()
        xss0,xss1,yss0,yss1,zss0,zss1 = self.bounds()
        for p in [[xss0, yss0, zss0],
                  [xss1, yss0, zss0],
                  [xss1, yss1, zss0],
                  [xss0, yss1, zss0],
                  [xss0, yss0, zss1],
                  [xss1, yss0, zss1],
                  [xss1, yss1, zss1],
                  [xss0, yss1, zss1],
                 ]:
            ss.InsertNextPoint(p)
        st = vtk.vtkPoints()
        xst0,xst1,yst0,yst1,zst0,zst1 = msh.bounds()
        for p in [[xst0, yst0, zst0],
                  [xst1, yst0, zst0],
                  [xst1, yst1, zst0],
                  [xst0, yst1, zst0],
                  [xst0, yst0, zst1],
                  [xst1, yst0, zst1],
                  [xst1, yst1, zst1],
                  [xst0, yst1, zst1],
                 ]:
            st.InsertNextPoint(p)

        lmt.SetSourceLandmarks(ss)
        lmt.SetTargetLandmarks(st)
        if rigid:
            lmt.SetModeToRigidBody()
        lmt.Update()
        self.applyTransform(lmt)
        self.transform = lmt
        return self

You can only keep the aspect ratio if you apply the same scaling in the 3 cartesian coordinates. If you want the origins to coincide you need to choose which axes to scale to match the target.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Three Dimensional Change Detection Using Point Clouds
We assume, that point clouds are registered (aligned in the same frame reference), can have different sources (dense image matching, laser ...
Read more >
A Tutorial Review on Point Cloud Registrations - Hindawi
A point cloud as a collection of points is poised to bring about a revolution in acquiring and generating three-dimensional (3D) surface information...
Read more >
PointSCNet: Point Cloud Structure and Correlation Learning ...
The DGCNN [40 ] simply concatenates the feature relationships of local sub-clouds in different dimensions, and the captured structural ...
Read more >
Denoising for 3D Point Cloud Based on Regularization ... - NCBI
A point cloud obtained by stereo matching algorithm or three-dimensional (3D) scanner generally contains much complex noise, ...
Read more >
Use Ground Truth to Label 3D Point Clouds
Point clouds are made up of three-dimensional (3D) visual data that consists of ... The 3D point cloud labeling job is different from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found