Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:36:20+00:00 2026-06-03T14:36:20+00:00

I have a cloud point obtained from photogrammetry from a person’s back. I’m trying

  • 0

I have a cloud point obtained from photogrammetry from a person’s back. I’m trying to interpolate it to get a regular grid, and for that I’m using scipy.interpolate with good results so far. The problem is: the function I’m using (scipy.interpolate.griddata) uses the convex hull of the cloudpoint in the plane x,y, thus giving as result some values that don’t exist in the original surface, which has a concave perimeter.

The following illustration shows the original cloudpoint at the left (what is displayed as horizontal lines is actually a dense line-shaped cloud of points), the result that griddata gives me in the middle, and the result I would like to get at the right — kind of the “shadow” of the cloudpoint on the x,y plane, where non-existing points in the original surface would be zeros or Nans.

enter image description here

I know I could remove the Z coordinate on the cloudpoint and check each grid position for proximity, but this is so brute-force, and I believe this should be a common problem on point-cloud applications.
Another possibility could be some numpy operation to perform over the point-cloud, finding a numpy mask or boolean 2D-array to “apply” over the result from griddata, but I didn’t find any (these operations are a bit beyond my Numpy/Scipy knowledge).

Any suggestion?

Thanks for reading!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:36:21+00:00Added an answer on June 3, 2026 at 2:36 pm

    Suitable masks can be constructed fast using KDTree. The interpolation algorithm used by griddata does not have a notion of “valid” points, so you need to adjust your data either before or after the interpolation.

    Before:

    import numpy as np
    from scipy.spatial import cKDTree as KDTree
    from scipy.interpolate import griddata
    import matplotlib.pyplot as plt
    
    # Some input data
    t = 1.2*np.pi*np.random.rand(3000)
    r = 1 + np.random.rand(t.size)
    x = r*np.cos(t)
    y = r*np.sin(t)
    z = x**2 - y**2
    
    # -- Way 1: seed input with nan
    
    def excluding_mesh(x, y, nx=30, ny=30):
        """
        Construct a grid of points, that are some distance away from points (x, 
        """
    
        dx = x.ptp() / nx
        dy = y.ptp() / ny
    
        xp, yp = np.mgrid[x.min()-2*dx:x.max()+2*dx:(nx+2)*1j,
                          y.min()-2*dy:y.max()+2*dy:(ny+2)*1j]
        xp = xp.ravel()
        yp = yp.ravel()
    
        # Use KDTree to answer the question: "which point of set (x,y) is the
        # nearest neighbors of those in (xp, yp)"
        tree = KDTree(np.c_[x, y])
        dist, j = tree.query(np.c_[xp, yp], k=1)
    
        # Select points sufficiently far away
        m = (dist > np.hypot(dx, dy))
        return xp[m], yp[m]
    
    # Prepare fake data points
    xp, yp = excluding_mesh(x, y, nx=35, ny=35)
    zp = np.nan + np.zeros_like(xp)
    
    # Grid the data plus fake data points
    xi, yi = np.ogrid[-3:3:350j, -3:3:350j]
    zi = griddata((np.r_[x,xp], np.r_[y,yp]), np.r_[z, zp], (xi, yi),
                  method='linear')
    plt.imshow(zi)
    plt.show()
    

    The idea is to “seed” the input data with fake data points containing nan values. When using linear interpolation, these will blot out areas of the image that have no actual data points nearby.

    You can also blot out invalid data after the interpolation:

    # -- Way 2: blot out afterward
    
    xi, yi = np.mgrid[-3:3:350j, -3:3:350j]
    zi = griddata((x, y), z, (xi, yi))
    
    tree = KDTree(np.c_[x, y])
    dist, _ = tree.query(np.c_[xi.ravel(), yi.ravel()], k=1)
    dist = dist.reshape(xi.shape)
    zi[dist > 0.1] = np.nan
    
    plt.imshow(zi)
    plt.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have a point cloud, and you want a surface that wraps those
I have a very large point cloud (> 100000 points) that I'd like to
I have a GUI application which works with point cloud data and a quadtree
I have a cloud of points that are supposed to represent a face. I
I am trying to implement a test project using the Point Cloud Library and
I have a 3D volume and a 3D point cloud. How can I draw
If I have a set of 3d points (AKA point cloud) what is the
Context: The Cloud We have a java-based web application that we normally host on
We have cloud-hosted (RackSpace cloud) Ruby and Java apps that will interact as follows:
I have an object made of points, lets say its point cloud, i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.