5
$\begingroup$

I have a large set of points that are close to manifold which I want to show in a ListPointPlot3D. Using part of the data set illustrates this

plot http://vollmer.ms/homog3d_0

plot http://vollmer.ms/homog3d_1

there are fewer data points in the middle.

But using all the data with

ListPointPlot3D[list[[2 ;; n]]]

results in

plot http://vollmer.ms/homog3d_2

Is there a better way to visualize this? Somehow something like 3d contour plot of the density.

$\endgroup$
6
  • $\begingroup$ Please note that part of your question is missing. $\endgroup$ Commented Dec 5, 2012 at 22:49
  • $\begingroup$ I am really sorry $\endgroup$
    – warsaga
    Commented Dec 5, 2012 at 22:53
  • $\begingroup$ Have you tried ContourPlot3D? $\endgroup$
    – soandos
    Commented Dec 5, 2012 at 23:03
  • $\begingroup$ yes as well as ListContourPlot $\endgroup$
    – warsaga
    Commented Dec 5, 2012 at 23:16
  • $\begingroup$ Although the title doesn't mention it, this seems to be about fitting a surface to a point list. If so, it's a possible duplicate of Construct a simple mesh or tetrahedral mesh from 3D image surface $\endgroup$
    – Jens
    Commented Dec 5, 2012 at 23:28

2 Answers 2

3
$\begingroup$

If your point cloud is extremely "thick" you can create a RegionFunction. Here is a simple example using points in the cube from -1 to 1 in all directions.

pts = RandomReal[{-1, 1}, {10^5, 3}];

ListPointPlot3D[pts, BoxRatios -> 1]

enter image description here

Now create the function.

nf = Nearest[pts];

inRegion[pt : {_Real, _Real, _Real}, eps_Real] := 
 TrueQ[Norm[nf[pt, 1][[1]] - pt] < eps]

This will give an approximation to the boundary enclosing the region. We decide a point is "in" if it is within .04 of one of the points in the original list, else it is outside.

d = 1.5;
reg = RegionPlot3D[
  inRegion[{x, y, z}, .04], {x, -d, d}, {y, -d, d}, {z, -d, d}, 
  Mesh -> False, PlotPoints -> 40]

enter image description here

This code was gleefully cribbed from some work here (Also here)

$\endgroup$
4
  • $\begingroup$ Thank you very much for the help. The problem with this approach is that I have outliers, and they get a ball around them, too. I am trying to use the cluster function, but this does not seem to work. $\endgroup$
    – warsaga
    Commented Dec 6, 2012 at 0:31
  • $\begingroup$ Try it with Norm[nf[pt, 2][[2]] - pt]; that should force there to be at least two nearby points in order to be considered "inside". $\endgroup$ Commented Dec 6, 2012 at 0:33
  • $\begingroup$ that is good but terribly slow.. $\endgroup$
    – warsaga
    Commented Dec 8, 2012 at 17:01
  • $\begingroup$ I'm mildly surprised about the speed issue. Can you give details on how to produce a data set typical of the sort you encounter? $\endgroup$ Commented Dec 8, 2012 at 20:54
1
$\begingroup$

In addition to what @Daniel Lichtblau described, let me give you a further idea. It is not completely clear whether it really helps in your case since frome the statement

I have a large set of points that are close to manifold

I can only guess and an example data-set would have been better.

What I would try is to estimate the local density of points and to make a ContourPlot3D (or a RegionPlot3D) which shows you the boundary of certain density.

You could for instance (and this is the difference to Daniels approach) calculate the distances from a point x to the next, say 30 points and then calculate the Mean or Median distance. This gives you kind of an estimation how dense x is surrounded by points.

Example:

data = ExampleData[{"Geometry3D", "StanfordBunny"}, "VertexData"];
With[{nf = Nearest[data]},
 density[x : {__?NumericQ}] := Mean[Map[Norm[x - #] &, nf[x, 30]]]
 ];
RegionPlot3D[
 density[{x, y, z}] < .01, {x, -.15, .1}, {y, -.1, .1}, {z, 0, .2}, 
 BoxRatios -> Automatic, PlotPoints -> 40]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ I like that. Could be useful in situations where sample points are relatively sparse. What I did kinda falls flat in such areas. (Plus 1, as they say. Whoever "they" is.) $\endgroup$ Commented Dec 6, 2012 at 14:48
  • $\begingroup$ @DanielLichtblau Thanks but it's stolen or at least inspired by the Kernel density estimation. $\endgroup$
    – halirutan
    Commented Dec 6, 2012 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.