Extending a straight line - delphi

There is a sloping LineSeries with two points showing a straight line. How can I calculate the Y value so the line continues infinitely in the same direction?
This line is like a guide-line that should follow along when values are added to another Series in the same chart. But must never change angle.
I'm using Delphi and Lazarus.

Suppose that the line passes through (x0,y0) and (x1,y1). The slope of the line k is given by:
k = (y1-y0) / (x1-x0)
So the line can be expressed as
y(x) = y0 + k(x-x0)
So you need to add points to the series whose x values are the minimum and maximum x values displayed on the chart. And whose y values are calculated as above.
This assumes that the line is not vertical, that is that x0 does not equal x1. If the line is vertical then the solution is trivial. Place points at the y values of the minimum and maximum values of the chart.

Related

Hough Transform Accumulator to Cartesian

I'm studying a course on vision systems and one of the questions posed was;
For the accumulator shown;
Determine the most likely r,θ combination representing the straight line of the greatest strength in the original image.
From my understanding of the accumulator this would be r = 60, θ = 150 as the 41 votes is the highest number of votes in this cluster of large votes. Am I correct with this combination?
And hence calculate the equation of this line in the form y = mx + c
I'm not sure of the conversion steps required to convert the r = 60, θ = 150 to y = mx + c with the information given since r = 60, θ = 150 denotes 1 point on the line.
State the resolution of your answer and give your reasoning
I assume the resolution is got to do with some of the steps in the auscultation and not the actual resolution of the original image since that's irrelevant to the edges detected in the image.
Any guidance on the above 3 points would be greatly appreciated!
Yes, this is correct.
This is asking you what the slope and intercept are of the line given r and theta. r and theta are not one point on the line, they are one point of the accumulator. r and theta describe a line using the line equation in polar coordinates: . This is the cool thing about the hough transform, every line in one space, (i.e. image space) can be described by a point in another space (r, theta). This could be done with m and b from the line equation , but as we all know, m is undefined for vertical lines. This is the reason the polar line equation is used. It is important to note that the line described by the HT r and theta refers to a line from the origin extending to the actual line in the image. This means your image line y = mx + b equation will need to be orthogonal to the polar equation. The wiki article on the HT describes this well and shows examples. I would recommend drawing a diagram of your r and theta extending to a line like this:
Then use trig to get two points on the red line. Two points are enough to give you m and b from the line equation.
I'm not entirely sure what "resolution" refers to in this context. But it does seem like your line estimator will have some precision loss since r is every 20 mm and theta is every 15 degrees. Perhaps it is asking what degree of error you could get given an accumulator of this resolution.

iOS Core Plot "Function transformation" - Y axis only origin

I cannot find how to do this for a while now, my graph is drawn ok every time but I want to move up my graph, like when you have f(x) + n. So, what I want to do actually is change Y origin, so I can draw my (x,0) points. I do not want to draw my points on X axis, I do not see the line that good. I want that my zero Y point actually starts at point three, but not to transform the graph at the same time. Here is picture of what I want to do (see the green line and Y point):
The plot space yRange controls the range of data visible. The image in the question looks like it has a location of negative one (-1) and length of 18. You can use the axisConstraints to keep the x-axis along the bottom of the plot area. If you don't want to use constraints, set the orthogonalPosition to the location of the yRange.

Detect aligned points in set of points OpenCV

Given a set of points on an image, I want to detect groups of aligned points as shown in the figure:
How can I do this? Any help will be appreciated.
This is a good potential application of the Hough Transform. The Hough space for lines is (r, \theta) where r is the distance from origin to closest point on line and \theta is its orientation.
Each point in x-y space becomes a sinusoid in Hough space as shown in the Wiki article.
The places where all the sinusoids intersect corresponds to a single line that passes through all the points. If the points are not perfectly colinear, the intersection will be "fuzzy".
The simplest algorithm to fit lines to points is to make a rectangular (r, \theta) accumulator array set to zero initially. Then trace a sinusoid for each point into this discrete (r, \theta) space, incrementing each accumulator element by a fixed amount. Find prospective line fits by looking for large array elements. The element coordinates give (r, \theta) for the fit.
Tracing the sinusoid is straightforward. If you have T accumulator bins on the \theta axis then each corresponds to an angle k(\pi)/N for some 0 <= k < T. So for k in this range, calculate the distance from the origin to the closest point of a line with this orientation passing through the point. This provides an r value. If there are R bins on the R axis and Rmax is the maximum value of r, then increment bin (floor(r/rMax*R), k).
As a start, you can try this:
List all lines that can be formed by selecting any two of these points (n(n-1)/2 ones for n points).
For any two of these lines, check if they are aligned (i.e. slope diff within say 10 degrees).
For each aligned pair lines, you can easily check whether other points are also aligned on these lines. And these points will be the aligned points you need.

Put a line on zero value of y axis

Helo,
Is it possible to put a line on zero value of y axis ?
Because i have negatives values so i changed orthogonal value of my axis to the lowest one on my datasource.
Thanks
Make second x-axis and position it at zero. You can leave off the labels and tick marks to just get the axis line. See the axis demo in the Plot Gallery app for an example of how to add additional axes to a Core Plot graph.

Find points betwenn two points?

In my game I draw the line using two points. I want to calculate the points between the line. Please give any formula for finding points between the two points.
If your two points are A and B then
r(t) = A + t(B - A) , where t is greater than or equal to 0 and less than or equal to 1
is the equation of the line joining A to B, and consequently allows you to find any point lying on the line between them (by using an appropriate value for t).
Does this help??

Resources