How can I segment a cloud if I know the rough shape it has to have? - point-cloud-library

I am trying to segment this 3D point cloud (this is the view at the top):
I want the "inner ellipsis", basically excluding the long red line on the right and some of the other points that stick out too much from the red ellipsis.
How/can I do this with PCL?

I would suggest using RANSAC but creating your own "elipse" model similar to the models used here: http://docs.pointclouds.org/trunk/a02954.html. Having done that I am sure it could be of benefit to others too.
Take a look at the code for e.g. SampleConsensusModelPlane or SampleConsensusModelCylinder for an idea how to build such a model:
$ cd ~/software/pcl
$ find . -name "sac_model_cylinder*"
./sample_consensus/src/sac_model_cylinder.cpp
./sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp
./sample_consensus/include/pcl/sample_consensus/sac_model_cylinder.h
Well, that's probably how I would do it (I haven't done it).

I would try RANSAC first, and then play with the parameters of the algorithm.
You can also try filtering the cloud a bit (again, try to play with parameters):
http://pointclouds.org/documentation/tutorials/remove_outliers.php#remove-outliers
http://pointclouds.org/documentation/tutorials/statistical_outlier.php#statistical-outlier-removal

If you know the radius of a rough circle that you are interested the data inside, why don't you apply a pass through filter to remove the unwanted parts. Check this link.
Pass through filter can be applied to different fields (x,y,z) and also to colors in RGB or HSI color space ranges.

Related

2D space organic projection

I'm currently working on a glsl shader (EDIT : I'm starting to think that a shader isn't necessarily the best solution and as I'm doing this in processing, I can consider a vectorial solution too) supposed to render something like this but filling the entire 2D space (or at least a larger surface):
To do so, I want to map the repeating patterns on the general leaves shapes that you can see on the top of the sketch below.
My problem is this mapping part : is it possible to find a function that project XY coordinates on the screen to another position in such a way that I can map my patterns the way I want? The leaves must have some kind of UV coordinates inside them (to be able to apply the repeating pattern) and the transformation must be a conformal map because otherwise, there would be some distortions in the pattern.
I've tried several lines of thought but I haven't managed to get the final result :
recursion :
the idea is to first cut the plane in stripes, then cut the stripes in leaves shapes that touch the top and the bottom of the stripes (because that's easier) and finally recursively cut the leaves in halves until the result looks more random. as long as the borders of the stripe aren't on the screen, it shouldn't be too noticeable. The biggest difficulty here is to avoid the distortion.
voronoi :
it may be possible to find a distance function guided by a vector field such that the Voronoi diagram looks more like what I'm looking for. However I don't think it will be possible to have the UV mapping I want. If it's the case, a good approximation woult do the trick, the result doesn't need to be exact as long as it isn't too noticable.
distortion :
it could also be possible to find a more direct way to do this projection. While desperately looking for a solution, I came across the fact that a continuous complex function is a conform map but I haven't managed to go any further.
Finaly, there may be another solution I haven't thought about and I would be glad if someone gave me a complete solution or just a new idea I haven't tried yet.

X and Y coordinates in R. Is there an obvious way to remove data that is a certain radius away from a given point?

I am trying to clean up some eye tracking data in which people are told to focus on the middle of the screen. However, the data is somewhat noisy and I am trying to clean it up in a proper way.
I have created some code that emulates the kind of data that I have and the methods I am trying to use as well as what I am presenting below.
The data complete with noise looks as follows:
I have tried to use a simple formula to throw all samples further than some pixels from the centre away such as:
results[results$x <= xmid+threshold & results$x >= xmid-threshold,]
But that results in data in a square shape rather than a circle:
I have tried to think about what to do here and have made it as far as to define a circle that encompasses the area that I am interested in:
However, I can not see a straightforward way to only pick data within that area.The solutions I have tried have required several for loops and still not given me the result I was hoping for.
I hope that some of you can point me in the right direction here. Maybe the problem is even trivial to solve in some manner that I have not yet considered? Thanks for reading this far and here is the code if you think that you can help :)
To check whether point lies in circular region with radius threshold around center xmid, ymid, you can use expression (^ denotes 2-nd power, squaring)
(x-xmid)^2 + (y-ymid)^2 <= threshold^2

How can I make DOT/neato graphs more compact without introducing overlap?

My question is essentially the same as this one but the given answer doesn't work for me.
Here is a sample rendering (source) with
compound=true;
overlap=scalexy;
splines=true;
layout=neato;
There is some unnecessary overlap in the edges but this isn't too bad, the main problem is all the wasted space.
I tried setting sep=-0.7; and here's what happens.
The spacing is much better but now there is some overlap with the nodes. I experimented with different overlap parameters and this is the only one which gives remotely acceptable results.
I tried changing to fdp layout and setting the spring constant attribute K globally but I just got stuff like this:
The source is all straightforward a--b--c sort of stuff, no fancy tricks.
What I want is for all edges to be shortened as much as possible (up to a minimum) provided that this adjustment doesn't introduce any new overlaps, which is where sep fails completely. That doesn't seem like it should be too hard for a layout engine to do. Is it possible with the graphviz suite? I don't mind changing rendering software, but I don't want to annotate the source on a per-node or per-edge basis.
My ideal result would be to minimize the deviation in edge length, considered one node at a time, i.e. each node would have edges of equal length apart from the necessary exceptions, but that's wishful thinking. The priority is to reduce the length of each edge with the constraint that this cannot introduce overlap.
I will accept partial solutions but they must be fully automatic and open source.
How can I do this? Thanks.
I found https://sites.google.com/site/kuabus/programming-by-hu/graphviz-test-tool, an interactive tool for parameterizing the many options and repeatedly rendering them. I went through the full list provided by the Java application, eventually ending up with this set of attributes:
overlap=false
maxiter=99999999
damping=9999999
voro_margin=.001
start=0.1
K=1
nodesep=999999999999
labelloc=c
defaultdist=9999999
size=20,20
sep=+1
normalize=99999999
labeljust=l
outputorder=nodesfirst
concentrate=true
mindist=2
fontsize=99999999
center=true
scale=.01
inputscale=99999999
levelsgap=9999999
epsilon=0.0001
I was not able to find a parameterization of neato that made producing the desired "moderately scaled" graph possible.
You should set
overlap = compress;
this should compress it at much as possible.
Try sep = +1; first, and then play with values between 0 and +1 to find the optimal setting for you.
I have a graph with 50 nodes and 68 edged (sorry cannot publish the whole picture, just a fragment). Found two reasonable presets (1 and 2):
digraph {
graph[
# 1. Less overlaps but less compact.
# This is the choice for now.
layout=neato; overlap=prism; overlap_scaling=-3.5;
# 2. More compact but some overlaps exist (may be adjusted by `sep`).
#layout=neato; overlap=voronoi; sep=-0.15;
# The following is common.
outputorder=nodesfirst, # Will always draw edges over nodes.
splines=curved;
]
node[fontname="Helvetica",];
node[shape=box;style="filled";penwidth="0.5";width=0;height=0;margin="0.05,0.05"];
edge[label=" ";color="#000080";penwidth="0.5";arrowhead="open";arrowsize="0.7";];
. . .
}

UIBezierPath find cross points / get all points

Is there any way to get all crossing points of lines created using UIBezierPaths?
I could also imagine a solution where I get all points inside the UIBezierPath and check them one after the other...
Thanks, kind regards, Julian
I get all the points of a UIBezierpath on this sample code, there is a mathematical approach for it and you need to know key points of the curve , this example probably will help you ,
you can take a look at :
Curvy UISlider
I will try to update it soon.

Hyperbolic Tessellations of a Pentagon in Mathematica

I want to implement this in Mathematica:
I realize I can use ParametricPlot to get the lines, and then use the Mesh option to fill in the colors. Can anyone tell me what a general formula for the equations of these lines are? Does it generalize to a regular n-gon?
I happen to have some code lying around that will do something close to what you want and you can view that code here: http://facstaff.unca.edu/mcmcclur/mathematicaGraphics/PTiling/.
A couple of comments are in order. The ideas behind the code are all described in Saul Stahl's excellent book, The Poincare Half-Plane - specifically, the chapter on the Poincare disk. I wrote the code to illustrate some ideas for a geometry class that I was teaching in 1999 so it must have been for version 3 or 4. I have done nothing to try to optimize the code for any subsequent version. Regardless, if you define the function PTiling on that page and then execute PTiling[5, 2*5 - 4, 3], you should (after several minutes) get something like the following:
Obviously, we have just a black and white picture illustrating the boundaries of the pentagons that you want but, hopefully, this is a good start. I think that one could use portions of disks, rather than circles, to get closer to what you want.

Resources