convex-hull

Non-convex polygon - preprocess to use convex hull algorithm

强颜欢笑 提交于 2019-12-23 15:30:59
问题 I used the convexHull algorithm to find the contour for some... irregular shape. It is not good enough though... Quite possibly because I can't guarantee that the shape I have is convex... I have a set of rectangles, and I would like to be able to get all points on the outside of the contour - but not throw any of the contour points out. The convex hull algorithm works great - but it works like the example on the right, so I lose some information on the contours. I want something that works

Determine whether a point lies in a convex hull in O(log n) time [duplicate]

喜你入骨 提交于 2019-12-23 07:05:22
问题 This question already has answers here : Test point for its position relative to the convex hull in log(n) (6 answers) Closed 4 years ago . I've researched several algorithms for determining whether a point lies in a convex hull, but I can't seem to find any algorithm which can do the trick in O(logn) time, nor can I come up with one myself.Let a[] be an array containing the vertices of the convex hull, can I pre-process this array in anyway, to make it possible to check if a new point lies

Drawing convexHull in openCV2 Python

坚强是说给别人听的谎言 提交于 2019-12-21 20:49:03
问题 So I am trying to draw the convexHull from a contour in python, however when i print the image it is not changing. roi=mask[y:y+h,x:x+w] roi = cv2.fastNlMeansDenoisingColored(roi,None,15,15,7,21) hull = cv2.convexHull(cnt) cv2.drawContours(roi,[hull],0,(147,0,255),2) cv2.imshow(str(i),roi) blank_image[y:y+h,x:x+w] = roi However, the images that show are the exact same if I did not include the code. I looked online, but cannot seem to find the answer. Here is a sample Image: 回答1: I used the

Triangulate a set of points with a concave domain

瘦欲@ 提交于 2019-12-21 12:14:14
问题 Setup Given some set of nodes within a convex hull, assume the domain contains one or more concave areas: where blue dots are points, and the black line illustrates the domain. Assume the points are held as a 2D array points of length n , where n is the number of point-pairs. Let us then triangulate the points, using something like the Delaunay method from scipy.spatial: As you can see, one may experience the creation of triangles crossing through the domain. Question What is a good

plot a circle/convex hull arround a given percentage of points

谁都会走 提交于 2019-12-21 06:38:34
问题 I have x=rnorm(100) y=rnorm(100) plot(x,y) abline(h=0); abline(v=0) From point (0,0) and going outwards I would like to draw a contour/circle/ellipse/freehand convex hull that encloses any given percentage of points. Is there any function or package that can automate this? I have tried the following so far but I can only get a circle with some extrapolation and approximation. I have tried this so far: #calculate radius r<- sqrt(x^2+y^2) df<-data.frame(radius=seq(0,3,0.1), percentage=NA) #get

Finding the convex hull of an object in opencv?

二次信任 提交于 2019-12-21 06:05:11
问题 I've written this based on the tutorial here but I'm unable to obtain the convex hull of the image (I'm using a similar hand image as shown in the tutorial). I get the source and edges output fine but the "Drawings" output which should draw the contour and convex hull lines don't show anything drawn and instead is completely black. Any ideas as to why this could be? #include <opencv/cv.h> #include <opencv/highgui.h> #include <opencv/cxcore.h> int main(int argc,char **argv) { cvNamedWindow(

Best Algorithm to find the edges (polygon) of vertices

半世苍凉 提交于 2019-12-21 05:11:19
问题 I have a large array of vertices, some of them are edges, some are redundant (inside the shape) and I want to remove those. The simplest algorithm I could think of is checking one by one if they hit the shape formed by the others. But it should be a very slow algorithm. I thought about picking one from the edge (the one farthest from origin per example) and calculate the longest path from this start... should get the edge path, right? Any suggestion? 回答1: The trick with polyhedral algorithms

Finding largest subset of points forming a convex polygon

匆匆过客 提交于 2019-12-20 11:55:55
问题 I'm looking for an algorithm for finding largest subset of points (by largest i mean in number) that form a convex polygon from the given set of point. I think this might be solvable using DP but i'm not sure. Is it possible to do this in O(n^3) ? Actually i just need the size of the largest subset, so it doesn't need to have unique solution Edit : just to keep this simple, Given input : a set of points in 2D Desired output : maximum number of points that form a convex polygon, like in the

Volume of convex hull with QHull from SciPy

前提是你 提交于 2019-12-17 18:53:37
问题 I'm trying to get the volume of the convex hull of a set of points using the SciPy wrapper for QHull. According to the documentation of QHull, I should be passing the "FA" option to get the total surface area and volume. Here is what I get.. What am I doing wrong? > pts [(494.0, 95.0, 0.0), (494.0, 95.0, 1.0) ... (494.0, 100.0, 4.0), (494.0, 100.0, 5.0)] > hull = spatial.ConvexHull(pts, qhull_options="FA") > dir(hull) ['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__format__'

What's an efficient way to find if a point lies in the convex hull of a point cloud?

邮差的信 提交于 2019-12-17 04:46:37
问题 I have a point cloud of coordinates in numpy. For a high number of points, I want to find out if the points lie in the convex hull of the point cloud. I tried pyhull but I cant figure out how to check if a point is in the ConvexHull : hull = ConvexHull(np.array([(1, 2), (3, 4), (3, 6)])) for s in hull.simplices: s.in_simplex(np.array([2, 3])) raises LinAlgError: Array must be square. 回答1: Here is an easy solution that requires only scipy: def in_hull(p, hull): """ Test if points in `p` are in