How to draw extended curve? - curve-fitting

My problem is, I have a curve with red dots as the image below. I want to extend the curve like the blue dots in the image. How can I do it?
I think finding Bézier curve with the red dots and somehow extending the Bézier function may work, but I am not sure about it. Any idea is welcome please!

Related

Find thick and odd shapes on an image

I am coding a specific edge detection algorithm. The image is black and red as given below. I am trying to extract red points that make a horizontal or vertical line and trying to get rid of anything that doesn't make a line shape. Some odd shapes are the ones that I later circled in yellow. The problem is that I cannot define the shapes exactly. The thing is they are 'thick'. They can be solid as in the upper left yellow circle or in pieces like the one below it. The only thing is they do not help me making a horizontal and vertical line on the image.
I am coding in Matlab, but any idea of algorithms are also welcome.

hough transform in a rectangular shape

Our aim, find vanishing point of rectangular shape. I want to apply hough transform this shape with y=mx+c. Than, after hough transform, I have to show two or more vote points on (m,c) axis second shape. I dont know how I apply. please help me.
The idea of Hough transform is that you basically draw all possible lines and then try to figure out which ones are really present in the image.
So, for your images, try to draw all possible horizontal/vertical lines and count the black points under each. Fot example - take horizontal line with y = 0(1,2,3..). Check the color of all points with x=[0...width] and y=0. If all or most of them are black - you have a line. Repeat with y=[1...height].
After you have the coordinates of all lines, you can find the gaps in each line in the same fashion - check all the points that should belong to the line and note the white ones. When you have enough white points in a row - there is a gap.
This method will help detecting few points of a figure on your first picture. Then you just have to connect them together to get your shape.

Remove incorrect pixels from polygons

I have generated set of points, that create polygonal areas border. On image below, there is an example of what I mean. The black "spots" should not be there and line should be "clear". I need to remove those points.
Now the problem is double. First, I dont know, how this situation is called. Its not aliasing or jagged edge, because those points are not obtained from line generating algorithm, but from contour generator.
And if not the name, than at least some push, how to solve this, would help me.
So far, I have tried convert this to chain code and simplify it, but that didn´t worked very well and it was rather slow. Convert those dots to geometry and use Ramer algorithm to simplify geometry works better, but it destroy some "fine" detail, that should be there.
You can try the following:
First search for these spots. From your figure it seems that the spots look something like the following:
1 1
1 1
That is, a square matrix of colored pixels. Such spots can easily be found by traversing the pixel matrix once.
Now once you identify these spots, you will need to check for the neighbouring pixels and see what pattern is the curve/line following and accordingly delete the unnecessary pixels.
Separate the contour curves and clean each one by itself.
For each contour:
If the curve is not closed, close it with a temporary line.
Flood-fill the contour curve to get a solid monochrome figure.
Run contour detection on the result. The edge of a monochrome figure will be a clean line.
Flood-fill the area outside the new contour curve.
Run contour detection one last time to restore the original contour.
Re-assemble the contours into a single bitmap.

Is there an algorithm for solving such projection reconstruction geometric problem?

We have a grid with red squares on it. Meaning we have an array of 3 squares (with angles == 90 deg) which as we know have same size, lying on the same plane and with same rotation relative to the plane they are lying on, and are not situated on same line on plane.
We have a projection of the space which contains the plane with squares.
We want to turn our plane projection with squares so that we would see it like it's facing us, in general we need a formula for turning each point of that original plane projection so that it would be facing us like on the image below.
What formulas can be used for solving such problem, how to solve it, has any one faced something like this before?
This is a special case of finding mappings between quadrilaterals that preserve straight lines. These are generally called homographic transforms. Here, one of the quads is a square, so this is a popular special case. You can google these terms ("quad to quad", etc) to find explanations and code, but here are some for you.
Perspective Transform Estimation
a gaming forum discussion
extracting a quadrilateral image to a rectangle
Projective Warping & Mapping
ProjectiveMappings for ImageWarping by Paul Heckbert.
The math isn't particularly pleasant, but it isn't that hard either. You can also find some code from one of the above links.

Algorithm to produce rounded edges and corners in a 3D mesh

Starting with a 3D mesh, how would you give a rounded appearance to the edges and corners between the polygons of that mesh?
Without wishing to discourage other approaches, here's how I'm currently approaching the problem:
Given the mesh for a regular polyhedron, I can give the mesh's edges a rounded appearance by scaling each polygon along its plane and connecting the edges using cylinder segments such that each cylinder is tangent to each polygon where it meets that polygon.
Here's an example involving a cube:
Here's the cube after scaling its polygons:
Here's the cube after connecting the polygons' edges using cylinders:
What I'm having trouble with is figuring out how to deal with the corners between polygons, especially in cases where more than three edges meet at each corner. I'd also like an algorithm that works for all closed polyhedra instead of just those that are regular.
I post this as an answer because I can't put images into comments.
Sattle point
Here's an image of two brothers camping:
They placed their simple tents right beside each other in the middle of a steep walley (that's one bad place for tents, but thats not the point), so one end of each tent points upwards. At the point where the four squares meet you have a sattle point. The two edges on top of each tent can be rounded normally as well as the two downward edges. But at the sattle point you have different curvature in both directions and therefore its not possible to use a sphere. This rules out Svante's solution.
Selfintersection
The following image shows some 3D polygons if viewed from the side. Its some sharp thing with a hole drilled into it from the other side. The left image shows it before, the right after rounding.
.
The mass thats get removed from the sharp edge containts the end of the drill hole.
There is someething else to see here. The drill holes sides might be very large polygons (lets say it's not a hole but a slit). Still you only get small radii at the top. you can't just scale your polygons, you have to take into account the neighboring polygon.
Convexity
You say you're only removing mass, this is only true if your geometry is convex. Look at the image you posted. But now assume that the viewer is inside the volume. The radii turn away from you and therefore add mass.
NURBS
I'm not a nurbs specialist my self. But the constraints would look something like this:
The corners of the nurbs patch must be at the same position as the corners of the scaled-down polygons. The normal vectors of the nurb surface at the corners must be equal to the normal of the polygon. This should be sufficent to gurarantee that the nurb edge will be a straight line following the polygon edge. The normals also ensure that no visible edges will result at the border between polygon and nurbs patch.
I'd just do the math myself. nurbs are just polygons. You'll have some unknown coefficients and your constraints. This gives you a system of equations (often linear) that you can solve.
Is there any upper bound on the number of faces, that meet at that corner?
You might you might employ concepts from CAGD, especially Non-Uniform Rational B-Splines (NURBS) might be of interest for you.
Your current approach - glueing some fixed geometrical primitives might be too inflexible to solve the problem. NURBS require some mathematical work to get used to, but might be more suitable for your needs.
Extrapolating your cylinder-edge approach, the corners should be spheres, resp. sphere segments, that have the same radius as the cylinders meeting there and the centre at the intersection of the cylinders' axes.
Here we have a single C++ header for generating triangulated rounded 3D boxes. The code is in C++ but also easy to transplant to other coding languages. Also it's easy to be modified for other primitives like quads.
https://github.com/nepluno/RoundCornerBox
As #Raymond suggests, I also think that the nepluno repo provides a very good implementation to solve this issue; efficient and simple.
To complete his answer, I just wrote a solution to this issue in JS, based on the BabylonJS 3D engine. This solution can be found here, and can be quite easily replaced by another 3D engine:
https://playground.babylonjs.com/#AY7B23

Resources